1

Okay so here it is, a mess was made and we need to reset a branch to a specific point in history. At this point I have gone into SourceTree and locally reset the branch to the appropriate commit.

How do I get the pushed branch to match? Currently it says I'm multiple commits behind and I'm not sure how to get rid of those changes.

If you need any other information please let me know. Thanks.

Casey West
  • 578
  • 5
  • 22
  • If you include the actual branch names and short versions of the commit ids, I could provide a better example – larsgrefer May 01 '18 at 18:42
  • Possible duplicate of [How to revert Git repository to a previous commit?](https://stackoverflow.com/questions/4114095/how-to-revert-git-repository-to-a-previous-commit) – phd May 01 '18 at 18:47
  • 1
    How about: Local branch name: iSo546 (SHA-1: 0001), Remote branch name: iSo546 (SHA-1: 0002) – Casey West May 01 '18 at 18:49
  • Read this answer: https://stackoverflow.com/questions/34519665/how-to-move-head-back-to-a-previous-location-detached-head/34519716#34519716 – CodeWizard May 01 '18 at 18:54

1 Answers1

3

git push origin local_branch:remote_branch -f

Be aware that this might be confusing for other people working which might have based their work on the old state.

EDIT: Adjusted to the names from your comment:

git push origin 0001:iSo546 -f

larsgrefer
  • 2,735
  • 19
  • 36
  • So this will make the current branch that is currently "x" commits behind locally the new head of the branch remotely? Will this overwrite the history? Also, the "local_branch" and "remote_branch"...is this the SHA-1? Thanks so much for the quick response. – Casey West May 01 '18 at 18:28
  • `local_branch` can be any refspec (a branch name, a tag name, `HEAD` or the SHA-1 of the commit). `remote_branch` is the name of the branch you want to change. – larsgrefer May 01 '18 at 18:38