Just finished working my way through this https://eu.udacity.com/course/how-to-use-git-and-github–ud775 very useful course in Git.
These are my notes:
- git init : Create a repository
- git status: Current status
- git log –oneline : View log of changes to a repo summarized on one line per commit
- git log –stat : Display the files that have been changed in the commit, as well as the number of lines that have been added or deleted
- git log -p : display the actual changes made to a file
- git log -p –stat : it displays both with the patch info above the stats info
- git log -p –stat -w : it displays both with the patch info above the stats info ignoring whitespace changes
- git log -p {SHA} : Display the actual changes made to a file for a specific commit
- git show: Details of current commit
- git show {SHA}: Details of specific commit
- git show -p –stat -w {SHA}: Details of specific commit see notes on git log above for use of flags
- git tag -a v1.0 : Add a Tag to current commit. NB. If you are using Git Bash or some other outing of the VI Editor to save your changes and quit, press ESCAPE, type :wq and press ENTER
- git tag : Display all tags in the repository
- git log –decorate : Details of current commit plus tag(s)
- git tag -d v1.0 : Delete a Tag
- git tag -a v1.0 a87984 : Add tag to a specific commit
- git branch : List all branches in repo
- git branch {branch name} : create new branch
- git branch -d {branch name} : delete branch
- git log –oneline –graph –decorate –all : The –graph flag adds the bullets and lines to the leftmost part of the output. This shows the actual branching that’s happening. The –all flag is what displays all of the branches in the repository.Running this command will show all branches and commits in the repository
- git merge : There are two types of merges:
- Fast-forward merge – the branch being merged in must be ahead of the checked out branch. The checked out branch’s pointer will just be moved forward to point to the same commit as the other branch.
- the regular type of merge
two divergent branches are combined
a merge commit is created - git commit –amend : Modify the latest commit
- git revert : Revert changes in a given commit
- git reset :used to reset (erase) commits
- git reset –mixed : takes changes in commit and moves them to the Working Directory
- git reset –soft : takes changes in commit and moves them to the Staging Directory
- git reset –hard : takes changes in commit and erases them
- q – quit out of viewing the log
Update
There is also another course on Udacity for using git and github to collaborate with other developers.
GitHub & Collaboration
This really is worth a look as it helps you build on the material from the previous course.
There is also an app for learning how to use Git and Github available here:
Git-it is a (Mac, Win, Linux) Desktop App for Learning Git and GitHub