This blog post is a HOWTO guide for using github while collaborating during hackathons. It does not cover git in detail.
One time setup
- Create github account by visiting https://github.com
- Generate SSH key locally and upload it to github
This setup ensures password-less (code) pull and push from github.
Per project setup
- Create a repo on github by submitting form at https://github.com/new
- Clone the repo locally using
Shell1git clone email@example.com:<username>@<reponame>.git
Note: It’s recommended to use the above style (SSH) instead of the HTTPS style so that, future submissions do not require retyping password.
- This will clone the (empty) repo into <reponame> directory.
- After “cd”ing that directory, you will be working on the master branch.
- Change to a new branch say
Shell1git checkout -b user1
- To see which branch you are currently and how much its modified use,
- Now modify the files.
- To add a new file, after creating the file, do
Shell1git add filename
- To remove a file, do
Shell1git rm filename
- All the changes made till this point are uncommitted, to see what changes will be committed in next commit, use
Shell1git statusShell1git diff
- Once the changes look good, commit them using
Shell1git commit -m "<commit message goes here>"
- Now, the changes have been committed locally to user1 branch, to push the changes back to remote server (github), use
Shell1git push origin user1
- Now the changes have been pushed to user1 branch on github server. Merge them by creating a pull request using master as base and user1 as branch to be merged.
- Step 13 can fail master has changed since the last time user1 was updated with master (in step 5). A fix for that is to execute following command before doing git push (step 12).
Shell1git pull origin master
After than perform another commit using git commit and continue from step 12.
Some more productivity tools focused on git