staminna staminna - 4 years ago 157
Git Question

making latest commit master (git)

Here's what I usually do:

$ git add . -Av
$ git commit -m "I want this to be master"

but when I try to push to remote, "everything is up-to-date" and the latest commit isn't master.

$ git branch
* (HEAD detached from f0efe1a)

How can I make the latest commit the Master?

Answer Source

Looking at the output of git branch, it appears you're not currently on any branch (called a "detached HEAD" state).

To be on the safe side, first create a new branch ("save-my-work") containing the commits you've created so far:

$ git branch save-my-work

Now, to include these commits in the master branch:

$ git checkout master
$ git merge save-my-work

Now you should by able to push as usual. If you're sure that master is in the state that you want it, you can delete save-my-work again:

$ git branch -d save-my-work

Tip: Use a graphical repository viewer like gitk to have a better overview of the state of the repository.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download