Search code examples
gitgit-resetgit-fetch

Update local reference for remotes without pushing


I'm developing a team script for fetching & pulling and need to test fetching. How do I modify my local version of the remote reference (without pushing) so that a fetch command will update my remote reference?

My repo is:

$ git show-branch
* [master] Merged PR 2
 ! [test] Merged PR 1
--
*  [master] Merged PR 2
*+ [test] Merged PR 1

$ git show-ref
09fc4e93cc5635589de5cf370b72a8133b20c64f refs/heads/master
bdf9bd23654ae2f0957742fa521958125abbdb11 refs/heads/test
09fc4e93cc5635589de5cf370b72a8133b20c64f refs/remotes/origin/HEAD
09fc4e93cc5635589de5cf370b72a8133b20c64f refs/remotes/origin/master

I'd like refs/remotes/origin/master at bdf9bd23654ae2f0957742fa521958125abbdb11 but refs/heads/master to remain at 09fc4e93cc5635589de5cf370b72a8133b20c64f

Just to be clear - I'm not asking about updating the origin, just my (local) references. I do not want to do git reset --hard test; git push --force - I don't think a push should be involved.


Solution

  • Found it; I was looking for update-ref:

    git update-ref refs/remotes/origin/master bdf9bd23654ae2f0957742fa521958125abbdb11