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
• 16,210 points
75 views

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
• 41,990 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
• 6,880 points

Related Questions In Git & GitHub

0 votes
1 answer
0 votes
0 answers
0 votes
1 answer
+13 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 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
205 views
0 votes
1 answer
0 votes
2 answers

difference between git remote and git clone

git remote add just creates an entry in ...READ MORE

answered Aug 7, 2018 in Git & GitHub by Kalgi
• 41,990 points
908 views
+1 vote
4 answers

error cloning remote repo 'origin'

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

answered Jun 3 in Git & GitHub by Sirajul
• 36,060 points
4,411 views