Pulling git goes into a branch that has not been checked out

I have a git repository that contains two branches, 1.0 and master. If I want to work with 1.0, I clone it using the following command:

git clone ssh://user@server/project -b 1.0 project-1.0

And everything's good. If I issue a command git branch, I see:

1.0

git branch -a as follows:

* 1.0
  remotes/origin/1.0
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

However, if someone else pushes the changes to master, and I make changes to 1.0 and try to push, it will fail because I need to update my repo with the main changes. To do this, checkout wizard, pull the changes, and then go back to 1.0:

git checkout master
git pull
git checkout 1.0

However, is there an easier way so that I can make the latest changes without prior control?

+3
source share
3 answers

git branch -a master. , git log master . , origin/master, . , master origin, , , git fetch; git log origin/master. , , git checkout master , .

, - master, 1.0 , , .

. 1.0, . -. git branch -d master (, 1.0, , origin/master, HEAD), , .

, - , 1.0, master origin/master.

+1

git fetch origin, t21 . "", 1.0.

a git pull a git fetch, a git merge.

+3

, /, do git push . origin/master:master (, ".).

+3
source

Source: https://habr.com/ru/post/1791433/


All Articles