Git best practice: getting a list of branches not tracked locally

I have a question about how to get new branches in a remote repository.

I know that there are (at least) two ways to continue:

  • git pull: pull the current working branch (fetch + merge) and get a list of new branches
  • git branch -rfollowed by git branch --track theBranch origin/theBranch: track the new branch

Is there a recommended way to continue (due to differences in behavior)?

+4
source share
2 answers

I am not sure that there is a recommended method, because each of these two options performs different actions and has different use cases.

git pull , , . .

git branch -r , .

git branch --track theBranch origin/theBranch

theBranch, . , :

git checkout origin/theBranch
git checkout -b theBranch

, . , , , git fetch ( git pull) . , , , - .

+3

@Tim Biegeleisen, , .

git pull --rebase, git pull git fetch, git merge FETCH_HEAD.

+1

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


All Articles