-6

QUESTION 1

HOW CAN I MAKE ANY OLDER COMMIT AS A HEAD IN GIT? (SAME BRANCH)

I need to make a new commit out of an already committed commit. (just like we use "git checkout" command to check a specific commit, after that How to make a new commit out of that commit).

While digging through Stackoverflow I got this

git revert --no-commit 3466c05386c7009e7c91bccb03147e817074143..HEAD

which is having more than 2K upvotes but I got an error

error: commit 3466c05386c7009e7c91bccb03147e817074143 is a merge but no -m option was given. fatal: revert failed

Could you help me to crack this with some simple commands?

QUESTION 2

FORCE GIT TO PULL AND OVERWRITE THE LOCAL COMMIT (WHICH NOT PUSHED YET) FROM REMOTE? (SAME BRANCH)

Similar to

git push -f

Where we force git to Push and overwrite the Remote, do we have any direct commands to do the opposite? Found many answers at Stackoverflow but not sure how to perform in a simpler way.

Please help.

619_RM
  • 1

2 Answers2

-1

To "over-write a commit":

git commit --amend

To force a local branch to be reset as your remote (or anything):

git fetch
git reset --hard origin/master
Ivan
  • 1,352
  • 2
  • 13
  • 31
  • Thanks for your response. I don't want to overwrite, I need to make a new commit out of an already committed commit. just like we use "git checkout" command to check a specific commit, after that How to make that to a brand new commit? – 619_RM Mar 26 '21 at 07:59
  • "git fetch" want me to Authorize Git Credential Manager :( – 619_RM Mar 26 '21 at 08:01
-1

screenshot of github desktop showing options!!.It can be done easily using using "github desktop". On github desktop goto -> History. Then right-click the commit that you had made and do revert commit. Now, Open your source file,no need to change anything, just do one or two little spacing. And save it. Wow !! You are ready for a new commit message.Now, do what you want !!

Dharman
  • 30,962
  • 25
  • 85
  • 135
Vishal Kumar
  • 183
  • 4
  • 9
  • Thanks for your response, but sadly the revert commit is not what I want, and that most of the time when I click Revert commit got the following error "To finish reverting, please merge and commit the changes." Please check this - https://stackoverflow.com/questions/4114095/how-do-i-revert-a-git-repository-to-a-previous-commit/21718540#21718540 Is what I was looking for but sadly getting a fatal error quite often. – 619_RM Mar 27 '21 at 03:31