4

git-fetch manual page says:

git fetch remote_repo 

will update "remote-tracking branches" of all branches from the remote repository.

What if I only need fetch a single remote branch?

I try to run:

git fetch remote_repo remote_branch 

It just stores infomation into FETCH_HEAD instead of creating a "remote-tracking branch" named remote_repo/remote_branch.

I know there is a solution:

git fetch remote_repo remote_branch:refs/remotes/remote_repo/remote_branch 

But it's too verbose.

Is there a simpler way to achieve this?

1 Answer 1

1

If the set of remote branches that you want to fetch is somewhat stable, you can edit remote.<name>.fetch with git-config to achieve that result:

git config remote.remote_repo.fetch remote_branch:refs/remotes/remote_repo/remote_branch 

That config will be picked up as default when running a bare git fetch:

remote.<name>.fetch The default set of "refspec" for git-fetch(1). See git-fetch(1). 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.