Skip to content

Instantly share code, notes, and snippets.

@grayson-palmer
Last active August 22, 2019 23:28
Show Gist options
  • Save grayson-palmer/fdc580a470efd9258afa514b3a1dbb9d to your computer and use it in GitHub Desktop.
Save grayson-palmer/fdc580a470efd9258afa514b3a1dbb9d to your computer and use it in GitHub Desktop.
Beginners Guide to Git

Beginners Guide to Git

This guide is to show basic commands and processes for utilizing a Local Git Repo. We will go over the following processes:

  1. How to initialize git
  2. How to check the status of files in the git
  3. How to stage files
  4. How to commit files

How to initialize Git

To initialize a local Git repo, follow the below steps

  • Open the terminal
  • Navigate to the folder for your repo
  • run the command git init**

Check Git Status

To check the status of the files in your Git repo to see if they need to be updated/added, use the git status command.

How to stage files

To add a file to staging, use the command git add [file_name_and_extension]

How to commit files

Once the files have been added to staging, you can now Commit the changes to the Git repo. If we had a file called sample.txt in staging that we needed to commit, we will use the git commit command. This command should NEVER** be run without the -m extension, which will add a comment to the commit. The first time committing will always look like this: git commit -m 'Initial commit' which tells us that this is the very first commit to this repo.

Example Code

Below is an example of what it would look like to use these commands:

```
cd git_practice
git init
git status
git add 'file1.txt'
git add 'file2.txt'
git commit -m 'Initial commit'
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment