Skip to content

Instantly share code, notes, and snippets.

@eoneill23
Last active April 12, 2019 01:20
Show Gist options
  • Save eoneill23/7b41683950c61b7e8dace94f050ce20b to your computer and use it in GitHub Desktop.
Save eoneill23/7b41683950c61b7e8dace94f050ce20b to your computer and use it in GitHub Desktop.

Beginner's Guide to Git

By Eric O'Neill

Git is a Version Control System (VCS) that allows a user to track changes to files as well as "go back in time" to see previous versions of the files. With those abilities, it is often used as a collaboration tool by developers around the world.

Github is a web application that hosts web applications and allows developers to upload or push files where they can later be downloaded or pulled by anyone who has access to the repository, allowing for increased collaboration.

Here are a few basic Git commands:

* pwd - Print working directory. Typing this command allows you to see where you are at within your computer's directories.

* cd - Change directory. Typing this command allows you to choose a directory on your computer to enter and work in.

* cd .. - Exit directory. Typing this command allows you to leave the directory your are currently in and "go back up one level" in your directory.

* ls - List. Typing this command allows you to see the files housed in the current directory.

* mkdir - Make a new directory. Typing this command allows you to create a new directory. mkdir is followed by what you want to name the directory. For example: mkdir new_directory.

* touch - Make a new file. Typing this command, followed by the file name, allows you to creat a new file within a directory. For example: touch new_file.txt

The basic steps of using Git are as follows:

  1. After creating a new directory (mkdir) and a new file within the directory (touch), begin tracking the directory by typing the command "git init"
  2. After initializing the git, add a file to track by typing the command "git add " to add then file to Git's staging area, which is essentially a holding pen for tracked files that you want to commit.
  3. Once you are ready to take a snapshot of your file in the staging area, type the command "git commit -m " to commit the file. The commit message should be a phrase with a present tense verb along with a brief description of the changes you made to the file you are committing.
  4. The command "git diff" allows you to see the changes made to a file.
  5. After the initial commit, you can add information to files by typing the command "echo 'text goes here' >> "
  6. Once a file has been committed, it then moves back to an unmodified status, ready to be edited and then moved to the staging area and committed once you are ready. You can check the status of the files you are tracking at any time by typing the command "git status"

Here is a visualization of the basic git flow:

git workflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment