Skip to content

Instantly share code, notes, and snippets.

@katychuang
Last active December 25, 2015 05:59
Show Gist options
  • Select an option

  • Save katychuang/6928841 to your computer and use it in GitHub Desktop.

Select an option

Save katychuang/6928841 to your computer and use it in GitHub Desktop.
Notes for Intro to Git/Github

Notes from Git Presentation Notes

Set up Git and GitHub

https://github.com

https://help.github.com/articles/set-up-git#platform-mac

What is a git repository?

  • The .git directory
  • A set of commit objects
  • A set of references to commit objects (“heads”)

What is a commit object?

  • A set of files
  • References to parent commit objects

What is a head?

  • A reference to a commit object
  • There is a default head in every repository. It's called master
  • A repository can have any number of heads
  • There will always be one and only one currently active head

Let's create a Repository

git init or simply git init

Create a file, stage it and commit it

  • cd <newfoldername>
  • touch pyladies.py
  • git status

It's “Untracked”

  • git add “pyladies.py”
  • git status
  • git commit -m “Initial Commit”
  • git status
  • git log

The three commands you'll use over and over

  • git add .
  • git commit -m “Fix infinite loop”
  • git push origin master

Now let's get set up to share it online

create a repo on github's website (or see pro-tip below)

git remote add origin [email protected]:<githubusername>/<reponame>.git

Pro-tip:

If you have curl installed, you can create a github repo from your command line. Check to see if curl is installed by typing curl --manual. The curl command for creating a github repo is curl -u '<githubusername>' https://api.github.com/user/repos -d '{"name":"<reponame>"}'

Edit the file, stage, commit, push

  • xdg-open pyladies.py
  • git add .
  • git commit -m “Add some content”
  • git push origin master

Branching & Merging

  • git checkout -b mybranch
  • git branch
  • git checkout master
  • git merge mybranch

Working with someone else's repo

  • Make a copy:

Git clone [email protected]:<githubusername>/<reponame>.git

  • Receive changes:

Git fetch

Git pull origin master

  • Upload your changes:

Git push origin master

Learn More

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