/git_cheatsheet

Creating a cheat sheet for creating a github repository

Working with git


Creating a GIT Repository

  1. Create a Repository on GitHub.com

Github

  1. Copy the link shown below Github
  2. Navigate to the folder in which you whish to create the repository
  3. Enter the command git init This initializes the local repository on YOUR COMPUTER .
  4. Enter the command git add remote origin <github-url> (This is hte command we copied from the website) This will set the upstream of your local repository connecting it to the online repository.
  5. Enter the command git add -A This tracks all the files inside of the added and deleted files inside of the local repository.
  6. Enter the command git commit -m '<message>' This commits the current changes to your local repository.
  7. Enter the command git push origin master This pushes your local repository to your online repository.

Terminal


Updating an existing repository

  1. git add -A This tracks all the files inside of the added and deleted files inside of the local repository.
  2. git commit -m '<message>' This commits the current changes to your local repository.
  3. git push origin master This pushes your local repository to your online repository.

Common Errors

GitBash

  • No tracking info

    1. Fix: Use `git pull origin master` instead.

GitBash

  • You created a git repository inside of your current repository

    1. Navigate to the child git directory (to find it check folders and see if you can use the command cd .git)

    2. Use the command rm -r .git -f to un-initialize the inner repository

    3. Add, Commit, Push as usual

GitBash

  • Updates were rejected

    1. git pull origin master
    2. Fix any merges if they appear
    3. git push origin master
  • I can't pull the class repository

    1. git reset --hard
    2. git pull origin master