git help <command>
- git status (to see changes in local space)
- git log (to see git commit history)
- git diff c6cd9..40abed (to see changes between these two commits)
- git diff (to see changes in local dir that have not yet been staged)
git mv oldname newname (to rename a source file)
The standard order to do things in:
- - git add
- - git commit
- - git pull (and check for conflicts)
- - git submodule update (to get Greg's changes to 'user' stuff)
- - git push
git checkout -- filename (to discard local changes to filename)
- git reset HEAD1 (to roll back a commit that has not been pushed)
- git reset --soft HEAD1
- * in both cases all changes to local workspace are retained
- * in the former case the files that got committed are put back to
- 'local modification' status. in the latter, they remain 'staged'.
- git stash (to record the current state of the working directory)
- git stash save (equivalent to the above)
- git stash show (to see what is in the stash)
- git stash apply (restore the local changes on top of any subsequent commits)
To mark a file as ready to commit: git add <filename>
To commit all "staged" files: git commit
To modify the most recent commit: git commit --amend - this allows you to add more files to the commit and/or modify the previous comment.
- don't say 'git commit -ammend' instead. this commits all changes with a comment of 'mend'.
To fetch data from the remote repo and merge it into your workspace: git pull
To "push" commits up to the remote repo: git push origin master (or git push)
Resolving merge conflicts
The conflicted file will contain lines like...
To resolve the conflict, follow these three steps:
- Edit the file to resolve the conflict (nothing fancy needed here).
- $ git add <filename>
- $ git commit