-
Notifications
You must be signed in to change notification settings - Fork 15
Git Help
##Quick Example##
An example on how to add code to develop (this is where we will upload, when it's ready it will move to master)
Switch to develop:
git checkout develop
After working on it:
git add [new files]
git commit
git push origin develop
You can update the content:
git pull origin develop
If you do a git commit before you push, but wished you hadn't do:
git reset <file>
If you want to undo the changes then (go back to the repository version):
git checkout <file>
##What to do if you contaminate Master##
If you accidentally push to the wrong branch, here are the steps I used to reverse it:
git reset --hard HEAD^
HEAD is now at e5a72d6 Fix markdown bullet points
This reversed the local branch (so if you committed but didn't push, you can stop here).
Notice the e5a72d6
, you will need that:
git push -f origin e5a72d6:master
Total 0 (delta 0), reused 0 (delta 0)
To https://[email protected]/fclaude/libcds2.git
+ 8960e71...e5a72d6 e5a72d6 -> master (forced update)
The -f
flag forces the push, even though the local one is older than on the origin.
##Reading Material##
Here are some resources to help you with Git. Of course, you don't have to read all of this :) I have put a ★ next to the ones I think should be understood.
###Introductions, to help you get started###
- Git for the Lazy
- Everyday Git in 20 Commands or so
- ★ A Note About Git Commit Messages
- ★ Git Flow (helps with managing branches),
- ★ Introduction to Git Flow - Even if you don't use git flow, it is a introduction to clean branching.
###Advanced Materials for the Inquisitive###
- Git for Computer Scientists gives an overview of how the internal graphs of Git work.
###References###
- Git Reference
- GitHub Help
- [Git Ready] provides tips
###Longer resources###
- Pro Git free eBook by Scott Chacon (a GitHub developer)