Git rocks
No news here, this post is mostly a note for myself, to remember some commands for git:
Creating a repository to be shared between several hosts (with an existing project)
On the server:
mkdir project.git
cd project.git
git --bare init
On the remote host:
cd project
git init
git remote add origin ssh://server/var/git/project
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
Now you can make the first commit:
git add .
git commit -m "First commit"
git push
Fix a mistake in a previous commit
- Save your work so far.
- Stash your changes away for now: git stash
- Now your working copy is clean at the state of your last commit.
- Use ‘git rebase -i’, and use the ‘edit’ command on the commit you want to edit
- Make the fixes. (If you just want to change the log, skip this step.)
- Commit the changes in “amend” mode: git commit —all —amend
- Your editor will come up asking for a log message (by default, the old log message). Save and quit the editor when you’re happy with it.
- The new changes are added on to the old commit. See for yourself with git log and git diff HEAD^
- Re-apply your stashed changes: git stash apply
- Continue happily with your life.
I’m a happy git user, it really rocks.