0

I have made checkout to my previous version in my repo.

git checkout 9dc64fa

Then I have made few changes and made few commits.

Right now when I check status it says:

# HEAD detached from 9dc64fa

How do I need to make push to update data on the server with new commit?

Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277
  • I think this post will help you http://stackoverflow.com/questions/5772192/git-how-can-i-reconcile-detached-head-with-master-origin – Laksitha Ranasingha Nov 12 '13 at 21:56
  • What do you want to push? How would anybody pull your changes down, if you don't have a branch pointing to the commits you want to send to the server? – user229044 Nov 12 '13 at 22:04

1 Answers1

2

Commits are intended to go on a branch. This way you can easily get to its tip, where all the fun happens, with a simple command:

git checkout <branch_name>

In your situation, you've made commits from an unnamed ref (to which you refereed by SHA-1), and git has no way to derive a branch name from that. To push as usual, first create a branch like this:

git checkout -b <new_branch_name>

If you actually wanted to commit to an already existing branch, you can still overwrite it, but do make sure that's really want you intend to do (check the checkout subcommand usage, or just delete the target branch beforehand).

JB.
  • 40,344
  • 12
  • 79
  • 106