Skip to content

Instantly share code, notes, and snippets.

@autocorr
Created January 28, 2015 00:43
Show Gist options
  • Save autocorr/8d9ae26fa454c9eac4da to your computer and use it in GitHub Desktop.
Save autocorr/8d9ae26fa454c9eac4da to your computer and use it in GitHub Desktop.
Essential git
# if you haven't setup a ~/.gitconfig, make one with these lines:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
# first enter the directory you want to version-control and initialize the repository
git init
# git works by storing the changes to files rather than the files themselves,
# so you first have to add the files, or start tracking them
# add all files in the current directory:
git add .
# commit your changes with a descriptive message:
# -a : add commit for each file that has been changed since last commit
# -m : use the string following the command as the message, rather entering
# a separate little editor window.
git add -am "My descriptive commit message."
# checkout your changes, this becomes more important when working with
# other branches, but just remember you have to do this before pushing
# changes to the server or other repo's.
git checkout
# now push your code to github!
git push
# this defaults to "git push origin master"
# the 'master' branch of the 'origin' repo
# if you're pushing to a forked repository you can follow the GitHub
# help documentation to setup your repo so that you can run
# "git push upstream master"
# if you want to sync the repo on your machine with the server/GitHub
# version use the "pull"
git pull
# for your own projects without collaborators, you really only need
# add -> [commit checkout push] + (pull)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment