Skip to main content

In case of succesfullyou had pushed your branch to remote repository (usually it's origin) and then you've done a succesfull rebase  (without merge) (So git rebase --abortgit rebase --abort gives "No rebase in progress?"progress") Commandyou can easily reset branch using command:

git reset --hard origin/{branchName}

Example:

maksym@maksym-leontiev$ ~/work/projects/{ProjectName} $ git status On branch {branchName} Your branch is ahead of 'origin/{branchName}' by 135 commits. (use "git push" to publish your local commits) nothing to commit, working directory clean maksym@maksym-leontiev$ ~/work/projects/{ProjectName} $ git reset --hard origin/{branchName} HEAD is now at 6df5719 "Commit message". maksym@maksym-leontiev $ ~/work/projects/{ProjectName} $ git status On branch {branchName} Your branch is up-to-date with 'origin/{branchName}. nothing to commit, working directory clean 

In case of succesfull rebase(without merge) (So git rebase --abort gives "No rebase in progress?") Command:

git reset --hard origin/{branchName}

Example:

maksym@maksym-leontiev ~/work/projects/{ProjectName} $ git status On branch {branchName} Your branch is ahead of 'origin/{branchName}' by 135 commits. (use "git push" to publish your local commits) nothing to commit, working directory clean maksym@maksym-leontiev ~/work/projects/{ProjectName} $ git reset --hard origin/{branchName} HEAD is now at 6df5719 "Commit message". maksym@maksym-leontiev ~/work/projects/{ProjectName} $ git status On branch {branchName} Your branch is up-to-date with 'origin/{branchName}. nothing to commit, working directory clean 

In case you had pushed your branch to remote repository (usually it's origin) and then you've done a succesfull rebase  (without merge) (git rebase --abort gives "No rebase in progress") you can easily reset branch using command:

git reset --hard origin/{branchName}

Example:

$ ~/work/projects/{ProjectName} $ git status On branch {branchName} Your branch is ahead of 'origin/{branchName}' by 135 commits. (use "git push" to publish your local commits) nothing to commit, working directory clean $ ~/work/projects/{ProjectName} $ git reset --hard origin/{branchName} HEAD is now at 6df5719 "Commit message".  $ ~/work/projects/{ProjectName} $ git status On branch {branchName} Your branch is up-to-date with 'origin/{branchName}. nothing to commit, working directory clean 
Source Link
Maksym
  • 4.6k
  • 4
  • 31
  • 48

In case of succesfull rebase(without merge) (So git rebase --abort gives "No rebase in progress?") Command:

git reset --hard origin/{branchName}

Example:

maksym@maksym-leontiev ~/work/projects/{ProjectName} $ git status On branch {branchName} Your branch is ahead of 'origin/{branchName}' by 135 commits. (use "git push" to publish your local commits) nothing to commit, working directory clean maksym@maksym-leontiev ~/work/projects/{ProjectName} $ git reset --hard origin/{branchName} HEAD is now at 6df5719 "Commit message". maksym@maksym-leontiev ~/work/projects/{ProjectName} $ git status On branch {branchName} Your branch is up-to-date with 'origin/{branchName}. nothing to commit, working directory clean