Tuesday, September 10, 2013

Simple Git Cheatsheet (beta)

This post does not cover setting up git for the first time or cloning the repo.

Starting Work - (already have a clone on your box)
> git pull origin master   (or branch name)
> git branch MyShinyNewFeature (create new branch)
> git checkout MyShinyNewFeature (switch to that branch)
Then do you work


Doing Work
Add all new files to current branch, commit files, push to remote server (origin)
> git add . (add all files)
> git commit -m 'message here'
> git push origin MyShinyNewFeature (save files to server)

Finishing your work for the day while on your branch
[MyShinyNewFeature] > git checkout master (switch to master)
[master] > git pull origin master  (update local copy of master)
[master]> git checkout MyShinyNewBranch (switch to your branch)
[MyShinyNewBranch] git merge origin master (merge master into your branch)
See Doing work to commit the merge.

Merging new feature into master
issue a pull request to integrate your branch into master, it better merge without any errors.

Random
> get fetch (every once in a while just run this)

Simple Definitions

  • add . (adds all files, you still need to commit)
  • commit - something you do after add
  • fetch - download the code from the server
  • pull - is a fetch and merge in one command
  • clone - copies code from the server to your box. Usually the first thing you do when starting a project.
  • origin - is a shortcut term for a remote server url
  • checkout is how you switch branches.  You can checkout local or remote branches.
  • branch - does branching stuff
  • .gitignore - this is a file that prevents certain files from being checked in.  There are several good ones out there.
Note: I like the github for Windows git client.  I like that it stores the password without any extra work.  It also generates ssh keys for you.
http://windows.github.com/



1 comment: