Skip to content

Instantly share code, notes, and snippets.

@fyaconiello
Created April 19, 2012 16:10
Show Gist options
  • Save fyaconiello/2422031 to your computer and use it in GitHub Desktop.
Save fyaconiello/2422031 to your computer and use it in GitHub Desktop.
Git Cheatsheet

###GIT CHEAT SHEET

start a new local branch of a remote repo (only need to do this once per repo)

change directories to your sites folder

cd ~/Sites/
git clone (repository address from github.com)
git checkout -b feature_name

note: you don't have to name it feature_name, you could name it by feature or any other identifiable tag

begin coding -- EVERY DAY
git checkout feature_name
git status

nothing should have changed since last time

save your progress to the internet -- end of day/feature

you should already be on your howard branch, but just in case

git checkout feature_name

track changes to modified files

git add .

track changes to new/deleted files

git add -u .

commit all tracked changes to your local branch

git commit -m "type in a short message about what you did"

change from your local branch to the master branch

git checkout master

pull down the latest master brach (it may have changed since you began work)

git pull origin master

change back to your local branch (where your changes are being stored)

git checkout feature_name

rewind all of the changes that you made to your local branch back to it's latest master

and then update its master to the new latest (pulled down in the previous step) lastly reapply your changes overtop of the new master branch

git rebase master

switch back to the master branch

git checkout master

merge your local branch into the "local" master branch

git merge feature_name

send the updated master branch into the internets

git push origin master

check your local branch out again so you are ready to code your next feature etc.

git checkout feature_name
IF YOU GET A MERGE CONFLICT

call me over.

@matthewferry
Copy link

Hey -- why not just use the shorthand git add -A instead of git add . immediately followed by git add -u .? If the point is to make sure new paths are created and to also track changes everytime, git add -A would do both without additional commands :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment