I’m always forgetting basic git commands, so I figured I’d make a list here I can reference. Hopefully it’s a help to you, too!

To clone a remote repo:

  1. Navigate to local folder

  2. Clone remote repo

    git clone {URL}

When making changes:

  1. Make local changes
  2. Add changes to staging area
    git add -A
  3. Commit changes to local repo
    git commit -m "message"
  4. Pull remote repo (to make sure no one has updated remote repo)
     git pull origin master
  5. Then push it to the remote repo
    git push origin master

Working with branches:

  1. Create a branch

    git branch [name of branch]
  2. Checkout branch

    git checkout [name of branch]
  3. add, commit change to local branch

    git add -A

    THEN

    git commit -m "message"
  4. commit push branch to remote

    git push -u origin [name of branch]

    (just first time to push it to remote and link the two together)

  5. in the future… you can just use

    git push

To merge…

  1. Switch to master change
    git checkout master
  2. Pull from master to make sure we’re up to date
    git pull origin master
  3. Merge branch
    git merge [name of branch]
  4. Push to remote
    git push origin master
  5. Check to see which things have been merged into master
    git branch --merged

To delete branch

  1. Check to make sure it’s merged (should show merged branch)
    git branch --merged
  2. Delete local branch
    git branch -d [branch name]
  3. Delete remote branch
    git push origin --delete [name of remote branch]
  4. Check everything
    git branch -a
    (double check all local and remote branches are deleted)