Reputation: 14254
dave@dave-dev:/media/dev/belgravia$ git branch
* (no branch)
master
I'm not sure how this happened, but is there a way I can merge no-branch into the master. I'm not sure how I can merge two branches when one of them is not a branch. The commits in no-branch seem to be loose. I'm afraid that checkout master
will cause data loss.
Upvotes: 46
Views: 20267
Reputation: 41
Maybe you can commit it on current branch(no-branch)
Then you have to do:
git reflog
After that you can get the id of this commit like 1d84d08
do:
git checkout master
git merge 1d84d08
Upvotes: 4
Reputation: 33
The reason you have (no branch) is you have done:
git checkout REMOTE_BRANCH_NAME
git checkout -b local_branch_new_name
git branch - a
local_branch_new_name
master
From here you can merge a branch into master the usual way. switch to master and do:
git merge local_branch_new_name
Upvotes: 3
Reputation: 993095
Use git show
to get the SHA1 commit ID of the current HEAD. With that information, you can't lose those commits.
Then, switch to master and:
git merge abc123
where abc123
is the SHA1 from the first step.
Upvotes: 70