Skip to content

Instantly share code, notes, and snippets.

@KVeitch
Last active June 3, 2019 05:27
Show Gist options
  • Save KVeitch/67c9bbe243d583adb72b27d96faa0401 to your computer and use it in GitHub Desktop.
Save KVeitch/67c9bbe243d583adb72b27d96faa0401 to your computer and use it in GitHub Desktop.
Beginners Guide to Git

The stages in the git workflow

  • Untracked
  • Unmodified
  • Modified
  • Staged
  • Committed

Local vs. Remote

Remember that the changes to files you have made on your local machine are not on on the central repository until you push them.

Git commands

git init initialize tracking of a file
git status check the git status of a directory/file
git add add file to track/push to the staging area
git diff see the modifications made to a file
git commit -m "Message" commit changed from the staging area

Basic order of git process

  1. git innit (to initialize a repository of the current directory)
  2. git add file_name.extension (stages the file)
  3. git commit -m "Simple message of changes" (submits the file or files from the staging area to the repository)
  4. git push (sends all commit(s) to the central repository)

Forking and Cloning

Forking is the process of creating a copy of a repository on Github from a different source. Cloning is the process of downloading a copy of the code that exists in a specific web address.


Running git status can will tell you what files you have modified. The results look something like this:

/git_and_gh_practice[master !]$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   travels.txt

no changes added to commit (use "git add" and/or "git commit -a")
git_and_gh_practice[master !]$ 

A basic chart of git work flow

Imgur

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