Skip to content

Instantly share code, notes, and snippets.

@bradybridges
Last active May 12, 2019 04:30
Show Gist options
  • Save bradybridges/65f4472f502ea1f9d7baaa712b3018f7 to your computer and use it in GitHub Desktop.
Save bradybridges/65f4472f502ea1f9d7baaa712b3018f7 to your computer and use it in GitHub Desktop.
Beginners Guide To Git

Beginners Guide To Git

What Is Git

Git allows you to track changes to a repository on your local machine. This can provide organization to a large project. Git in combination with Github allows a team of people to work on a project.

Basic Git Commands

  • git init Initializes file for tracking
  • git add <file> Adds file to staging area
  • git commit -m 'message' Commits changes with message
  • git push Pushes changes to remote repository

Git Workflow

  1. Directory Initialized
  2. Directory Unmodified
  3. Changes Made To Files(modified)
  4. Add changes To Staging Area
  5. Commit Changes To Repository
  6. Directory Returns to Unmodified

Markdown Diagram

Things To Remember

Do Not Clone Repositories into Existing Git Directories

If you submit a change to a fork, you must open a pull request to merge it with master branch

Useful Article

Introduction To Git.

Example Of Pushing To Github

  501  cd Documents/git_and_gh_practice/
  502  ls
  503  echo 'Another hobby of mine is mountain biking.' >> hobbies.txt
  504  cat hobbies.txt 
  505  git add hobbies.txt
  506  git commit -m 'Add Hobby'
  507  git push

Branches

Branching a repository creates a copy of a project that is not linked to the master repo. So you can experiment and make changes freely. Once you are confident that your changes are ready to be added to the master repository, a pull request can be submitted. This signals that your code is ready to be merged with the master branch. This is useful because it allows many people to work on different areas of a project simultaneously. It also splits the project into smaller pieces making it easier to track the changes in the project as it progresses.

Branching Diagram

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