Skip to content

Instantly share code, notes, and snippets.

@adamsjr8576
Last active July 9, 2019 22:44
Show Gist options
  • Save adamsjr8576/f911dfde5e875188f5d846364c74e422 to your computer and use it in GitHub Desktop.
Save adamsjr8576/f911dfde5e875188f5d846364c74e422 to your computer and use it in GitHub Desktop.
Documenting Git knowledge thus far using Markdown

A Step-By-Step on Git Flow

  1. Initilize git using git init once you are in the working directory you would like git to track
  2. Git is now tracking the working directory
  3. at any point you can use git status to check the status of the files in your directory
  4. If a file is added to the directory then it will initially be untracked
  5. add file to staging area via git add <file>
  6. commit file to finalize addition via git commit -m '<insert text>'
  7. once you run git status it should say "nothing to commit, working tree clean"
  8. Any time a file is modified or created then you will need to repeat the git add and git commit commands to finalize those modifications

Things To Remember When Using Git

  • For the first commit made always make the text 'Initial commit'
  • you can use git diff <filename> before changes are added to see what changes have been made
  • you can use git log --format=oneline to see a log of each commit on one line

Example of a proper initial commit using Git

johnadams~/git_and_gh_practice$ git commit -m 'Initial commit'
[master (root-commit) bd60f9a] Initial commit
Committer: John Adams <[email protected]>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

git config --global --edit

After doing this, you may fix the identity used for this commit with:

git commit --amend --reset-author

2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 hobbies.txt
create mode 100644 travels.txt

Example showing how to get the git status

You can get the status of your files and work within git by using the command git status and it will look something like this johnadams~/git_and_gh_practice$ git status

Image of Git and Github Flow

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