初始化本地 git 库 git init
在github上创建库
添加远程push地址
git remote add origin
(备注:为什么这个origin不能修改?) git@git.com/xxx/xxx.git
我认为的是 origin 就相当于远程库了,所以 绑定远程分支
git branch --set-upstream-to master origin/master
我操作的有问题吗?报错为:
git branch --set-upstream-to master origin/master
fatal: branch 'origin/master' does not exist
最后我是这么解决的 :
git push -u origin master
谢谢.
The origin/master branch did not exist before your first push
If you change the background, it may be fine. For example, after git clone, change the upstream of the new local branch to origin/master
Add
git fetch
after step 3.
The name ofgit init
初始化本地仓库,默认分支是master
.origin can be modified at will, and N remote repositories can be added. But at this time the warehouse is remote and not available locally.
After executing
git fetch
, the remote warehouse will be obtained locally, and the branch is origin/*, that is, all branches of the remote warehouse will be pulled down. The remotemaster branch corresponds to the local origin/master.
After executing
git branch --set-upstream-to master origin/master
, set the remote master branch as the local tracking branch. When executinggit pull
, you can Directly pull the remote master to the local origin/master branch and master branch. If you executegit branch --set-upstream-to master origin/master
后,将远程的 master 分支设置为本地的跟踪分支,当执行git pull
时,可以直接将远程的 master 直接拉取到本地的 origin/master 分支和 master 分支,如果执行git fetch
, only the remote master branch will be pulled to the local origin/master branch.