============== Some git koans ============== Forking a repository on github ============================== 1. **In a browser**, log into github.com. 2. Go to https://github.com/ngs-docs/ngs-scripts and click "fork" (upper right). This will make a copy of that git repository under *your* account. It should leave you at http://github.com//ngs-scripts. 3. Select the URL about midway down the page ('https://...') and copy it to your clipboard. Hint: There's a handy little button on the right to do this. 4. Go to your EC2 command line, and type:: git clone https://github.com//ngs-scripts.git where the last bit is pasted from what you copied in step 3. 5. Change into the ngs-scripts directory:: cd ngs-scripts/ and poke around. 6. Marvel. Note that what is in your directory is the same as what you can see via the github interface. 7. **In a browser**, go back to your copy of ngs-scripts. Select 'README.md' in the top-level directory. 8. Select 'Edit'. 9. Change something in the text box (e.g. add "Kilroy was here.") 10. Click "Commit changes". 11. Note that in the browser, README.md has been updated. 12. **In the command line**, note that README.md hasn't changed. The repositories are distinct and separate. 13. Type:: git pull https://github.com//ngs-scripts.git master to *pull* the changes from github into your local copy. 14. Now README.md is the same in both places!! What you have done here is *cloned* your repository, then *edited* your file in the original repository, and then *pulled* the changes from the original repository into your new repository. Edit local file and push to github ================================== **At the command line**, 1. Edit the README file (either with a local editor like 'pico', or with Dropbox, or something; e.g. do:: cp README.md ~/Dropbox (edit it) cp ~/Dropbox/README.md . to update it remotely and copy it back over). Use 'more' to make sure your local copy is different. 2. Type:: git diff to see your changes. The lines with '+' at the beginning are your new changes, the lines with '-' at the beginning are what they replaced. 2. Type:: git commit -am "made some changes" to commit the changes as things you want to do. (At this point, you could also type 'git checkout README.md' to replace the changed file with the original.) 3. Type:: git push https://github.com//ngs-scripts.git master 4. Marvel that the local changes are now viewable on github.com directly! What you have done here is to edit files in one repository, and then *pushed* the changes to another (remote) repository. Create a new repository; add some files to it. ============================================== Let's create a new repository, just for you. **In a Web browser**, 1. Go to http://github.com/ and click on "New repository." 2. Make up a repository name (it will suggest one; ignore it.) 3. Select the "initialize this repo with a README." 4. Select 'Create repository." 5. Now, clone it to your EC2 machine:: git clone https://github.com//.git 6. Change into the new repo directory:: cd 7. Create a new file:: echo hello world > greetings.txt 8. Add it to your repository:: git add greetings.txt 9. Commit it:: git commit -am "added greetigs" 10. Push it to your github repository:: git push https://github.com//.git master 11. Go check it out on the Web -- do you see greetings.txt?