Reputation: 1097
Besides the branch master
i have created another branch develop
.
Now i have made some commits to develop
and did a pull origin develop
on the test-server instead of pull origin master
.
Is it possible to get back to my master
branch on the test-server and revert all files that i fetched in pull origin develop
?
I have already tried git checkout master
and then git pull origin master
, but it says:
* branch master -> FETCH_HEAD
Already up-to-date.
and no fles from develop
have been reverted.
$ git branch -av
develop 3e22f0c some-commit
* master 3e22f0c [ahead 6] some-commit
remotes/origin/HEAD -> origin/master
remotes/origin/develop 3e22f0c some-commit
remotes/origin/master 86198f0 some-commit
Upvotes: 0
Views: 133
Reputation: 11870
When you execute git pull origin <branch_name>
on a branch different from the one you currently check out, git will execute two operations: it will 1.) fetch the latest version of from remote and 2.) merge it into the branch you have checked out.
In essence, this just leads to an extra commit that you want to revoke. There are a couple of options to do this:
1.) do a hard reset to the previous commit: git reset --hard HEAD~¹
2.) do a hard reset to the HEAD of your remote tracking branch git reset origin/master
3.) the same hard reset can be done with git checkout -B master origin/master
4.) revert the merge commit with git revert -m 1 HEAD
(not a great option since it leads to two extra commits in your log)
Upvotes: 1