rpq
rpq

Reputation: 1327

Difference between git fetch <remote> and git fetch <remote> <branch>

I had a remote branch that I was already using and I wanted to update the refs on it, so I typed git fetch <remote> <branch> and the branch did not update with the latest refs. I found I had to use git fetch <remote> (without a branch) to get the current remote updates on that branch. Could someone please explain?

Upvotes: 1

Views: 93

Answers (1)

michas
michas

Reputation: 26495

git fetch <remote> <branch> will fetch the single given branch from the given remote and store it in FETCH_HEAD.

git fetch <remote> will use the default refspec which is usually configured as remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* and therefore will fetch all branches and stores them in the corresponding remote branch.

Upvotes: 4

Related Questions