Now, onto actually using git. First, make a folder called git(yes, all lower case) on your desktop. Everything we do now will be in terminal / command prompt, so let's get going!
First, let's tell git who we are by defining our name and email that all our commits will be contributed to. This is a one time process. In a terminal window, type
git config --global user.name "FIRST_NAME LAST_NAME" git config --global user.email "firstname.lastname@example.org"
There will be no "Name/Email added successfully" after you press enter, and that is completely normal. Alternatively, you can use the command
git config --list --show-origin to show your current settings for git.
A clone of a repo means you are downloading a copy of it on your device. There are two ways of doing this
You can directly download a .zip of the entire repo by heading to the repo's page and using the code.
Let's clone our markdown repo from previous chapter on our device. In terminal, type
cd and drag your git folder from desktop on terminal and press enter. (Reminder: cd let's you change your directory)
Every command for working with git starts with, *drum roll*
First get your git repo link, which is different from your URL link by heading over to the clone section and copying the url ending with
To clone the repo, in terminal type
git clone <url>.
Now, there will be a new folder in your git folder with your repo name!
Pull is to update your code from repo in the server. Let's update our README.MD file in our repo. Head over to your repo on GitHub and paste the following code:
# Markdown Repo This is updated text in my repo!
Now in your terminal, go inside your repo folder by typing
cd folder-name and type
git pull and open README.MD
The git add command is the first command in a series of operations used to save to a Git repository the changes you made to files and folders therefrom. The command sends changes you made to a staging area. You can then use git commit to commit those changes to the main repository. There are two ways to add files from your local repo to staging.
git add path/to/file.extension
git add .
You can either add specifc files by their path, or you can use a period / full stop to add every single file that was changed to the staging environment.
Before you commit changes, the
git add command is required. The commit command takes files added from the
git add stage and creates a snapshot with date / time stamp and changes made to the
code in the project histroy timeline LOCALLY. To commit, we simply type
git commit -m "Commit Message". Do not forget to add -m "Commit Message", because if you do, it will open a text editor in terminal depending on what platform you're using and it's a little difficult to work around. You can use multiple
git add commands before you solidify it using a
git push command is used to upload our changes to the git server(in our case, to GitHub).
Let's quickly practice everything we've learnt.
- Make changes to your README.MD file. It could be a haiku, something about yourself, anything you want to write using the markdown format. Add in a title, sub title, a list of items for your grocery shopping later tomorrow.
The world is your playground
- Create a new file in your repo folder and call it
LINK.MD. Write more text here, the contents don't really matter.
- Link both your files together. You README.MD and LINK.MD should have a "Go To X" button, which when clicked, takes you to the other file.
- In your terminal, add both files and commit them to your repo.
- To link files, all you have to do is add
[Go To Readme.md](README.MD).
- To add / commit, while in your repo folder, in terminal type
Chapter 6: Collaboration and Contribution
git add . git commit