将Eclipse中的项目上传至oschina

将Eclipse中的项目上传至oschina

本地电脑已经具备如下条件:

  • 在oschina上传或者下载过代码
  • 配置过oschina的密钥

在oschina上创建项目,然后上传本地工程

创建过程中如果去勾选readme,会有简易的命令行入门教程。如下所示:

cd existing_git_repo/new_git_repo
git remote add origin https://git.oschina.net/GangGangDu/JoeyUtil.git
git push -u origin master

existing_git_repo指是本地已经存在的git仓库。
在执行git remote add origin https://git.oschina.net/GangGangDu/JoeyUtil.git可能会出现fatal: remote origin already exists.的错误。
这里写图片描述
解决方法如下:

git remote rm origin
git remote add origin https://git.oschina.net/GangGangDu/JoeyUtil.git

如果还不生效,可以通过

vi .git/config
进入vi编辑器手动删除[remote “origin”]。
将Eclipse中的项目上传至oschina_第1张图片

我们也可以创建一个新的new_git_repo, 运行git bash, 然后按照如下步骤。

  • git status可以查看当前目录下文件状态
  • git commit需要提交信息

cd projectFolder
git init
git status
git add .
git status
git commit -m “create util”
将Eclipse中的项目上传至oschina_第2张图片

你可能感兴趣的:(Git)