Reset commit of remote branch

0 votes

Reset commit of remote branch

Branch A

git add modify files
git commit -m "ISSUE FIX A"
git push origin A

Found problems from ISSUE FIX A commit, so I want to reset this commit

git reset HEAD^
git commit -m "Reset commit HEADNUM"
git push origin A

then error message

 ! [rejected]        BRANCH A -> BRANCH A (non-fast-forward)

How to reset commit of the remote branch?

Aug 13, 2018 in Git & GitHub by Hannah
• 18,570 points

2 answers to this question.

0 votes
use git push --force origin A Because you are trying to edit the history.

you can amend your commit without using git reset by using git commit --amend to amend the last commit.
answered Aug 13, 2018 by Kalgi
• 52,370 points
0 votes

Just fix the issue on your local, save it and:

git add .
git commit --amend --no-edit
git push --force-with-lease

The commit and its hash will change keeping the same commit message. The --force-with-lease overwrites your remote branch with your local, unless someone else committed on it.

answered Aug 13, 2018 by Nilesh
• 7,040 points

Related Questions In Git & GitHub

0 votes
1 answer
0 votes
0 answers
0 votes
1 answer

error on branch master nothing to commit, working directory clean, when try to commit my changes.

Hi@akhtar,  If you already have a .git/ folder ...READ MORE

answered Apr 10, 2020 in Git & GitHub by MD
• 95,320 points
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
+2 votes
1 answer
0 votes
3 answers

difference between git remote and git clone

HI.... GIT REMOTE add just creates an entry in ...READ MORE

answered Jul 11, 2020 in Git & GitHub by anonymous
+2 votes
5 answers

error cloning remote repo 'origin'

ERROR: Error cloning remote repo 'origin' hudson.plugins.git.GitException: Could ...READ MORE

answered Jun 3, 2019 in Git & GitHub by Sirajul
• 59,090 points