Git fetch remote branch and remote ref

how do i get the remote branch and update the local git link for this branch without executing the current branch? For example, if I do this

$ git pull origin master 

origin / master merges into my current branch. This also does not work.

 $ git fetch origin master 

How then do I check

 $ git branch -r -v origin/HEAD -> origin/master origin/master 7cf6ec5 test 02 

that origin / master ref "7cf6ec5 test 02" is lagging. The true origin / master is "XXXXXX test 03". git fetch only pulled the changes to FETCH_HEAD, it did not load the local origin / master ref. What is the step to update this ref?

Note:

 $ git fetch origin 

Get all deleted links and update them, but unfortunately (a) a lot of mess. (I don’t want someone else 30-50 random branches to know that someone will not want mine) and (b) when the branches are deleted by origin, these links are not deleted locally the next time I do git fetch origin , which means this path ends abruptly.

The question is, how to extract only one branch and update its ref locally?

+8
git
source share
3 answers

I think I'm looking for it

 $ git fetch origin master:refs/remotes/origin/master 

This is similar to the fact that unlike 'w10> origin master' I really see that ref is being updated.

Any reason why the answer is wrong? Something I should be afraid of?

+5
source share
 git fetch origin 

this will delete all the remote branches and update the remote tracking branches for them.

You can now do one of two things.

 git checkout other-branch git merge origin/other-branch git checkout - 

or

 git push . origin/other-branch:other-branch 

The last option is fine, if you know that it will be a quick merge forward.

+1
source share

You can always specify refspec for the git fetch command. In particular, if you want to update other-branch , you can do:

 git fetch origin other-branch:other-branch 

This will extract the current tip of refs/heads/other-branch from the source and put it in a local branch with the same name.

Another way: continue and:

 git fetch origin other-branch 

And then recreate the local branch:

 git branch -l -f other-branch -t origin/other-branch 

-l exists as a security mechanism. It will create a reflog entry so that you can revert to the previous version if you need to.

0
source share

All Articles