github - How does git bind the remote branch when pushing?
PHP中文网
PHP中文网 2017-05-02 09:48:59
0
2
724
  1. Initialize local git repository git init

  2. Create a library on github

  3. Add remote push address

    git remote add origin(Note: Why can’t this origin be modified?) git@git.com/xxx/xxx.git

  4. I think origin is equivalent to the remote library, so bind the remote branch

    git branch --set-upstream-to master origin/master

Is there something wrong with my operation? The error reported is:

git branch --set-upstream-to master origin/master
fatal: branch 'origin/master' does not exist

In the end, this is how I solved it:

git push -u origin master

Thank you.

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
我想大声告诉你

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.

git init 初始化本地仓库,默认分支是 master.

git remote add origin(Note: Why can’t this origin be modified?) git@git.com/xxx/xxx.git

The name of

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 remote
master 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 executing git pull, you can Directly pull the remote master to the local origin/master branch and master branch. If you execute git 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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template