cbolorinos
cbolorinos

Reputation: 21

How to move commits on top of master if HEAD is detached?

sorry, noob here.

I've researched this, but everyone refers to branches and I'm not sure I'm dealing with a branch.

A while ago I messed up the website I'm working on over the process of 4 commits. So I went back four commits, and just kept working from there. Since then I've saved maybe 10 commits, but I never "officially" made a branch, so I'm not sure if I'm on a branch. I'm definitely not on MASTER because I left it a long time ago.

How do I make what I'm working on into the MASTER branch?

added per request:

$ git branch -v 
* (detached from 626a6f1) aea944b trying to make new branch 
  bottom_drop_side_menu 46e7358 quick save 
  lowermenu 4e89d92 So here's a kind of nice lower menu. Client doesn't dig :( 
  master 2071f52 the categories arent working...

Upvotes: 2

Views: 425

Answers (2)

VonC
VonC

Reputation: 1323273

Simply make a new branch where you are (on the detached HEAD aea944b):

git checkout -b tmp

And replay it on master:

git rebase master

Then merge tmp in master

git checkout master
git merge tmp

See also "Why did my Git repo enter a detached HEAD state?".

Upvotes: 2

André R.
André R.

Reputation: 1647

you are in 'detached head' state. one option would be to stash the changes you have right now and apply them to master.

git stash
git checkout master
git apply

you might have merge conflicts to solve between the state you are on now and the current state of master.

Upvotes: 0

Related Questions