git clone https://github.com/TreeHacks/github-workshop.git
- This will grab the latest code from github and save it to your machine
- Generally, you only need to do this once per project
git checkout -b [branch_name]
- You can think of branches as "versions" of the codebase
- A common git pattern: create a branch ("feature branch"), make changes, then merge that feature branch back into the main branch
- Create a new file in the "participants" folder named [Your first name]_[Your last name].md
- Add some info about yourself! (eg what school you go to, favorite language, etc.)
git status
This will show you a list of changes that have been made since the last commit (we'll talk about commits later)
git add [path]
or, to add all changed files:
git add .
This adds all of the changes we've made to the "staging area". This doesn't do much in and of itself, but allows us to...
git commit -m "commit message"
You can think of commits as a set of changes - each is associated with an author, timestamp, etc.
git log
With 'git log', we can take a look at the entire history of our branch. At the top, you should see the commit that you just added, followed by commits from other users.
We now have a change committed locally on our computer, but we want to "push" it up to the github repository so that others can view and modify it. Use:
git push origin [branch_name]
To create a new branch on the github repo that matches the one on your local
A pull request lets you notify everyone in the repository of your changes and enables those changes to be merged into the main branch. You can do this from the github UI
Press the big green merge button on github!
Once other contributors have added their changes, you probably want to get an updated version of the main branch with everyone's work on it.
First checkout the main branch:
git checkout master
And pull:
git pull origin master