Difference between revisions of "Using Github and Git for Code"
From Bridges Lab Protocols
Davebridges (Talk | contribs) (wori) |
Davebridges (Talk | contribs) m (made references into a list) |
||
Line 4: | Line 4: | ||
==Useful References== | ==Useful References== | ||
− | Github cheatsheet - http://help.github.com/git-cheat-sheets/ | + | * Github cheatsheet - http://help.github.com/git-cheat-sheets/ |
− | Git manual - http://schacon.github.com/git/user-manual.html | + | * Git manual - http://schacon.github.com/git/user-manual.html |
− | Git installation - http://help.github.com/linux-set-up-git/ | + | * Git installation - http://help.github.com/linux-set-up-git/ |
− | Forking an existing repository - http://help.github.com/fork-a-repo/ | + | * Forking an existing repository - http://help.github.com/fork-a-repo/ |
==Making Changes to Code== | ==Making Changes to Code== |
Revision as of 21:04, 5 March 2012
Useful References
- Github cheatsheet - http://help.github.com/git-cheat-sheets/
- Git manual - http://schacon.github.com/git/user-manual.html
- Git installation - http://help.github.com/linux-set-up-git/
- Forking an existing repository - http://help.github.com/fork-a-repo/
Making Changes to Code
- It is generally best practice to work on a branch for each improvement, then merge that back into a working master branch once you are finished.
- Create a branch. Each branch is a complete clean version of the code, and will not affect other branches.
git branch [name of your new branch]
- Switch to that branch
git checkout [name of the branch you want to switch to]
- Make some changes to a file and save it (i use Notepad++ in windows and Gedit in linux)
- Commit the changes. This saves those changes to your revision history. This is useful to find out when changes happened and to go back to when things were working. You want to commit often! Try to make the message useful, as in I did X to Y. Try not to do "changed stuff" or "fixed some mistakes"
git commit -m "This is the message describing the commit"
- Intermittently push those changes back to Github (especially if you are working on a couple of computers)
git push origin [name of your new branch]
- Once you are done working on a branch go back to your original branch (normally master) and pull in changes from your modified branch. Once its working, you can optionally delete the branch if you dont think you are going to need it in the future.
git checkout master git merge [name of your new branch] git branch -d [name of branch you want to delete]