I have the following scenario:
I have 3 commits in my local repo, like this:
initial -- a -- b
where both
master
andorigin/master
point atb
.After that, I fetch the origin, and the repo looks like this:
initial -- a -- b -- c -- d
where
master
points atb
andorigin/master
point atd
.After that, I merge and now
master
also points atd
.
I can reset my master
branch by doing git reset --hard b
.
What I would like to do is to also reset the origin/master
ref to commit b
. And, I do not mean that I want to reset remote repository to some state - I want to do this locally only. No pushing. I want the remote to remain unchanged. What I want is to change the knowledge of my local repo with regard to the state of the remote repo.
How can I do that?
I can probably change some files in .git directory, but which files? Or is there maybe some git command for it?
Why do I need that? Because I want to be able to replay the scenario, to easily test a git-based project management I'm working on. I would like to replay the same situation, in order to see how it behaves if I change the conditions only slightly.
cp .git/refs/heads/master .git/refs/remotes/origin/master
(after resettingmaster
to commitb
) a valid solution?branch1
tracksbranch2
but I want to use all git's mechanisms before I code something (to use something was already coded, and is well-tested, instead of adding new code). And also I prefer to operate in exact same conditions as in real case, to avoid some unexpected differences in behaviour.