seemaisms
seemaullal
Seema Ullal
What is Git
Setting Up Your Terminal
Useful Git Commands
Merging
Rebasing
Interactive Rebasing
Have a Good Readme
What is Git
Setting Up Your Terminal
Useful Git Commands
Merging
Rebasing
Interactive Rebasing
Have a Good Readme
Git is a distributed version control system that stores data using snapshots of changes over time
Distributed
Everyone has a local copy of the code – a local repository that is contained in the .git folder
You usually also have a remote, central repository with the shared code (Github, Bitbucket, etc)
Snapshots
various states of how the code looked at different times
COMMIT OFTEN– you can easily go to different "milestones" in your code
What is Git
Useful Git Commands
Merging
Rebasing
Interactive Rebasing
Setting Up Your Terminal
Have a Good Readme
Step 2: Add to your .bash_profile or .bashrc (or zsh)
source ~/.git-completion.bash
Step 1: Download the script
What is Git
Setting Up Your Terminal
Merging
Rebasing
Interactive Rebasing
Useful Git Commands
Have a Good Readme
lets you "save your changes for later". also useful for moving your changes from one branch to another
# on a branch 1
git stash save half-done-feature
# technically can just do git stash
# now you can switch branches!
# ... later
git stash pop
# (or git stash apply if you don't want
# to delete the stash)
lets you "save your changes for later". also useful for moving your changes from one branch to another
# show a list of all your stashes
git stash list
# shows all the file changes in a stash
git stash show
# can specify which stash by adding
`stash@{<stash-number>}` after any command
A safer way to commit. Also allows you to commit parts of a file. Shows you each section you changed and asks if you want to commit it.
// dangerous! Who knows what you are commiting
git commit -am 'Made some awesome changes'
// instead, double check everything you are commiting
git commit -p 'Made some awesome changes'
// can also do git add -p
A safer way to commit. Also allows you to commit parts of a file. Shows you each section you changed and asks if you want to commit it.
Note: Use with caution. Allows you to amend a previous commit. Good for changing commit messages or fixing small errors you made.
# add the file(s) with the changes you want
git add -p
git commit --amend
# (can optionally edit commit message here)
git push -f
# force push only if amended commit already on
# Github (not a good sign!)
useful alternative to stashing
( create a "temporary" commit then undo later)
also a quick way to fix committing on the wrong branch
# create a temporary work in progress commit
git add -A
git commit -m 'wip'
# switch branches, make unrelated changes,
# do whatever else you wish to do
# go back to your branch with the 'wip' commit
git reset HEAD^
# now there is no 'wip' commit but all of its changes still exist
# the "^" is actually short for "HEAD^1"
you can also specify how many commits to go back:
git reset HEAD^2 or git reset HEAD~2
see http://www.paulboxley.com/blog/2011/06/git-caret-and-tilde
what if you "git reset" and then change your mind?
git diff
git status
git log
git blame <file_name>
git grep <reg_exp>
git revert
git checkout -- <file_name>
git cherry-pick <commit>
... and many more!
Highly recommend using an IDE that has built in version control (PyCharm, WebStorm, RubyMine, PHPStorm, etc.) or a graphical interface for Git (Github for Mac, Source Tree, etc.)
What is Git
Setting Up Your Terminal
Useful Git Commands
Rebasing
Interactive Rebasing
Merging
Have a Good Readme
common
ancestor
Branch A
Branch B
# on branch A
git merge branchB
c1
c0
c2
common
ancestor
Branch A
Branch B
# on branch A
git merge branchB
c1
c0
c2
c4
merge commit
What is Git
Setting Up Your Terminal
Useful Git Commands
Merging
Interactive Rebasing
Rebasing
Have a Good Readme
# on branchA
git rebase branchB
common
ancestor
Branch A
Branch B
c1
c0
c2
# on branchA
git rebase branchB
common
ancestor
Branch B
c1
c0
c2
Branch A
# on branchA
git rebase branchB
common
ancestor
Branch A
c1
c0
c2
Branch B
# on branchA
git rebase branchB
common
ancestor
Branch A
c1
c0
c2
Branch B
Rebasing rewrites history.
Use it with caution.
What is Git
Setting Up Your Terminal
Useful Git Commands
Merging
Rebasing
Interactive Rebasing
Have a Good Readme
What is Git
Setting Up Your Terminal
Useful Git Commands
Merging
Rebasing
Have a Good Readme
Things people don't want to (and probably won't) do:
clickable table of contents
features
steps to run the app (include info on seeding, etc.)
link to a deployed version [include this if screenshots don't do your project justice]
next steps
contributors
how to contribute
license
* must haves
Pro Git book **
** = highly recommended
Seema Ullal
seemaisms
seemaullal
www.seemaullal.com/blog