需要新建Git仓库并添加本地项目
1 新建目录git_dir,把需要上传到git的文件enc.jar复制到这个目录下
2 初始化当前目录作为Git仓库:
git init
3 添加目录下的文件到本地仓库:从工作区提交到暂存区
git add enc.jar
# git add . 添加当前目录下的所有文件
4 提交staged的文件,从暂存区提交到本地代码仓库
git commit -m "提交enc.jar"
5 使用命令行添加远程仓库的地址。
git remote add origin https://github.com/...../abc.git
6 git pull
此时可能会报错,提示输入username,password
输入后,再git pull,可能仍然会报错:
gitThere is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> merged0.9.6
是因为本地分支和远程分支没有建立联系 (使用git branch -vv 可以查看本地分支和远程分支的关联关系) .根据命令行提示只需要执行以下命令即可
git branch --set-upstream-to=origin/master master ,把远程master分支,关联到本地master分支
# git branch --set-upstream-to=origin/远程分支的名字 本地分支的名字
再次运行git pull会发现git_dir目录下有很多从远程master分支上下载下来的文件
7 提交文件
git push origin master ,从本地代码库提交到远程代码库的master分支
使用 git branch -a 能看到本地和远程的所有分支。
参考:
https://blog.csdn.net/theonegis/article/details/80115316