SETTING UP A REPOSITORY
* Style guide for writing commit messages: http://udacity.github.io/git-styleguide/
Keep commits small. Make one commit per logical change.
Messages written in present tense.
Compare changes between files
- Command works on untracked files (not added to staging area yet)
- Hard filesystem deletion
- Works on files, not directories
- Inverts changes made from the previous commit
- History of commits is not lost
- Good for shared repos
git commit --amend
- Run when nothing is staged*
- Amended commits are new commits. Previous commit will no longer be available
- Don't use on public commits which other devs have based their work on
COLLABORATING AND SYNCING - GITHUB
When you have multiple branches, you can:
- merge all branches into your local repo, and push to remote repo, or;
- push individual branches from local to remote repo
- Use to see what everybody else has been working on
- Fetched content is represented as a remote branch. Does not affect local repo
- Follow with git merge origin/master to merge remote repo changes to local repo
- Then push new merge commit back to the remote repo
- git push origin master
- To be used if remote repo may have changes in the form of merged commits
- Git pull command = git fetch and git merge
- using rebase ensures a linear history by preventing unnecessary merge commits
- can use following command to ensure git pull uses rebase automatically, instead of merge:
git config --global branch.autosetuprebase always
- Tags are not automatically pushed with other git push commands
INSPECTING A REPOSITORY
Git shortlog & git log
Displays list of commits made.
- Down arrow scrolls through commit history.
- Press q to exit.
- date format = yy-m-d
- Integrate independent lines of development, created by git branch, and integrate them into a single branch
- use git status to ensure HEAD is pointing to merge receiving branch
- use git fetch to ensure all branches are up to date with remote changes
- Purpose: to point out particular commits / make them stand out
- Example: label with a version number
- Tag stays locked to a commit
*HEAD points to the current location
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets