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) added_mongodb_auth master serviceworkers_branch
How can I make the latest commit the Master?Answer1:
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
$ 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
$ git branch -d save-my-work<hr />
Tip: Use a graphical repository viewer like
gitk to have a better overview of the state of the repository.