Git & Forking Practice Using the Command Line
Follow these step-by-step instructions.
- Press the Fork button to create a 'copy' of this page on your own personal github repo.
- Click on the green Copy or Download button. Either copy the link, or click on the clipboard to create a copy.
Open up your Terminal (Mac) or git bash (PC) navigator.
Type pwd. What is returned?
Type ls. What is returned?
Use cd to navigate to a folder where you want to copy a local version of your github repo.
- cd Documents to navigate to your Documents folder.
- Protip: For new navigators of the command line, typing ls after changing your directory will keep you oriented.
Using the mkdir command, create a folder called DS_DS5K in your 'Documents' folder, (or anywhere you'd like) to keep your class materials. -Note that we use underscore instead of blank spaces between files. This is a good habit to develop, as spaces can be difficult to interpret by some types of code.
Now, let's clone the repo: git clone [link]
type ls What do you see?
cd into your file.
use touch to create a .txt document. The name of the .txt file can be anything you want.
Let's delete the random notebook in here:
- use rm to delete the notebook in this file.
- use rmdir to delete the 'pizza' file.
Note: These commands permanently delete files and folders.
Play around with this repo in your local directory, using the terminal. This is a directory you can play around and test different commands without worry of losing your homework.
We can now push this repo back to our personal page.
In this order, type these commands in the terminal
- git add . (This adds all of the contents in your directory)
- If you ever want to add just one file/document/img/notebook, type git add [name of file]
- git commit -m "upload message"
- git push
- Go back to your repo. What happened?
- You should now see the changes reflected on your page.