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,520 points
1,522 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
• 52,350 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,060 points

Related Questions In Git & GitHub

0 votes
0 answers

Updates were rejected because the tip of your current branch is behind its remote counterpart

We have a branch called dev We access it ...READ MORE

May 5, 2022 in Git & GitHub by Kichu
• 19,040 points
9,087 views
0 votes
1 answer
0 votes
0 answers
+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
4,047 views
+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
23,498 views
+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,230 points
39,763 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP