Marco Zanetti
Marco Zanetti

Reputation: 4271

Can't see my latest pushes on github project. What's the head of it?

I wanted to revert quite a lot of commits on my gitHub project: https://github.com/MarKco/workItOut

To do so I followed the instructions I found here: Why does git revert complain about a missing -m option? and How to revert Git repository to a previous commit?

I used a wide combination of resets, reverts and all. I must admit I didn't understand everything I was doing, I was on hurry and wanted this change (which looked fairly simple to me) to be done.

I managed to have in my working directory the old version, which sounds good. I committed and pushed, but what I see on the repo is strange:

* a2c09a3 (HEAD) Test
* 55fb272 Code optimization
* 3d26a26 Removed unused files which prevented compiling
* 6433aa5 Hopefully revert to f2c37d5
* ee730b5 Revert "Revert "Merge branch 'kevinoo-master'""
* 8fca74c Revert "Revert "Revert "Merge branch 'kevinoo-master'"""
* 2f64778 Revert "Removed proguard lines from build.gradle"
* 7349cc4 Removed proguard lines from build.gradle
* 85a4d64 Revert "Revert "Merge branch 'kevinoo-master'""
* b7b6328 Revert "Merge branch 'kevinoo-master'"
*   056df48 (origin/master, origin/HEAD, master) Merge branch 'kevinoo-master'
|\  
| * 30b9e79 (origin/kevinoo-master, kevinoo-master) Making it work again
| *   de5af76 Make it work again

I see two heads: the a2c09a3 (which is the one I want to be the real head, and it's the one I see in my working directory) and 056df48 which is labeled as "origin/master, origin/HEAD, master).

If I launch git status, I get

HEAD detached from 056df48
nothing to commit, working directory clean

and if I try to push, I get

Everything up-to-date

On github I don't see any commit after the 056df48.

So... I'm stuck :-/ How can I make the repository have a single head, and the head i want?

Thank you everybody

Upvotes: 0

Views: 1227

Answers (1)

Mohammad AbuShady
Mohammad AbuShady

Reputation: 42899

you're in a detached head mode, git doesn't know what branch to push this commit to, you can easily tell it which branch explicitly

Assuming you want to push to master

git push origin HEAD:master

after that you can git checkout master

Another option would be merging this detached branch to your local tracking branch first

From your log the HEAD hash is a2c09a3 so

git checkout master
git merge a2c09a3
git push origin master

Upvotes: 1

Related Questions