Girish Garg
Girish Garg

Reputation: 58

I checked out to a previous commit in git repo. Did some changes and made a commit there. Pushing changes to master branch says everything up to date

I checked out to a previous commit in my master branch. Then did some changes and made a commit there itself. Now I wish to push the changes to master branch. But it says everything up-to-date.

In short I did this,

  1. git checkout 573789f3 (a previous commit in master branch)

  2. Made some changes there and commited them there itself.

    git add .

    git commit -m "message"

  3. Now when I do git push origin master, I get Everything up-to-date

Also, I want this commit to be the HEAD of the master branch

Upvotes: 0

Views: 41

Answers (1)

Mort
Mort

Reputation: 3549

The problem is that once you checkout a commit, you are no longer on master. So when you push master it's up to date because it's unchanged!

Am I right that you want to remove the latest commit, and add a commit of your own. I would suggest you do it like

git checkout master # if you didn't do it already
git reset --hard 573789f3  # Or HEAD~
<do your changes>
git commit -am 'message'
git push --force # The --force will be necessary as you are obliterating the previous HEAD commit

Upvotes: 2

Related Questions