I am using SourceTree and am still fairly new to git. I was attempting to merge a version together with another to begin working on the next version on its remote branch but it didn't work as I expected. I was able to get back to the commit I wanted by just pulling it to my local, but now it just has a "HEAD" tag while the "origin/[version]" is still about 5 commits up. Is there anyway to force the remote branch to forget everything I have done and track the current commit I am using? Thanks.
Asked
Active
Viewed 1.2k times
3 Answers
5
You can use -f
option to push forcefully to remote.
git push -f origin <branch-name>

Vishwanath
- 6,284
- 4
- 38
- 57
-
Ok yes I did a hard reset and a push to the version, but should I see the "origin/[version]" move back down the tree? Or will it just change in its current place? Just wondering because it didn't move. – gma Mar 06 '15 at 16:53
-
It should move back down the tree, rather you should not see the commits at all anywhere. – Vishwanath Mar 06 '15 at 16:55
-
What does it say when you do `git pull` after you have done this? – Vishwanath Mar 06 '15 at 16:56
-
It just pulls back the thing I wanted to delete. Nothing happened to it. – gma Mar 06 '15 at 17:31
-
Try `git push +
` after git reset. If this doesnt work try altenratives in this question http://stackoverflow.com/questions/448919/how-can-i-remove-a-commit-on-github – Vishwanath Mar 06 '15 at 17:36 -
I fixed it, I just left out the branch name and it did what I wanted – gma Mar 06 '15 at 17:40
2
in the remote git server cd to .git folder and
git reset --hard HEAD^
the above commands removes the latest commit, then push using
git push -f
In bare repo

TEDDY
- 821
- 10
- 24
1
I fixed it, I just made sure I was in the commit I wanted, then I ran
git push -f origin
no branch name, and it worked.

gma
- 198
- 1
- 4
- 11