Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chrisdbasham317/6b0b66054c62a74598a279a425bb62af to your computer and use it in GitHub Desktop.
Save chrisdbasham317/6b0b66054c62a74598a279a425bb62af to your computer and use it in GitHub Desktop.
Beginner's Guide To Git
#A Beginner's Guide By A Beginner - Intro to Git
##What exactly is **Git**?
* Git is a *Version Control System*
* *Version Control System* is a term used to describe a process in which changes can be monitored, tracked, and reverted back to if needed.
* Git is often used in software development
* Git requires some knowledge of programming languages to become proficient.
##How Do I Use **Git**?
I learned Git in a *Command Line Interface* system on Mac called "Terminal"
###Before we get to far into Git, It is important to understand how to navigate through directories while in terminal. Here are some basic commands that will help do just that!
1. cd + <directory name>
- Brings you into the stated directory
2. cd ..
- Brings you 1 Level back out of your current directory
3. ls
- Lists the files/directories that are within the directory you are currently in
4. mkdir <directory name>
- creates a directory in the directory you are currently in
5. touch <file name>
- creates a file in the directory you are currently in
6. pwd
- prints the file path to your current location
![Terminal Navigation](https://cdn.tutsplus.com/mac/authors/legacy/Marius%20Masalar/2012/07/20/terminal-step6.png)
This image shows us the individual used the "cd" command to go into their "Desktop" directory. They then used the "touch" command to create 3 files.
###Git itself also has some commands we need to know.
1. git init
- This lets git know you are about to start tracking some files so it can create a repository
2. git add
- This adds files to the ##staging area## of Git
3. git commit -m <message>
- This commits the staged files as they are into your repository with a **message** that summarizes what your commit entailed
4. git status
- This shows you the current status/area of all of the files being tracked by git
![Git Flow Chart](https://git-scm.com/book/en/v2/images/lifecycle.png)
This is the chart that I was shown to help explain what is happening when you use the above commands in Git
##Bringing it together
*If I am in my home directory and I wanted to create a new directory called "Git_example".
-I would enter the command `$ mkdir Git_example`
*To make sure everything I'm doing is in my new directory, I will need to go into it.
-I do this by entering `$ cd Git_example`
*Then say I want to create some files.
-My command would read `$ touch git_commands.txt`
*Now we are at a point where I want to start a git repository.
-Here I type in `$ git init` and my computer is getting ready to start tracking my files in my **Git_example** directory.
*To add my new file:
-$ `git add git_commands.txt
-This brings my file into the git repository, and moves it into the staging area.
*For now this is all I want as a baseline to my project.
-To create this starting point I would enter `$ git commit -m "Initial commit"
-This moves my file into the **unmodified** position in our git flow chart.
##So you know have essentailly the same knowledge level of Git as I do! Practice, experiment, and **ENJOY**!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment