Skip to main content

Keep your repo up to date

  • git clone - creates a local copy of the repository for you to work in

    git clone https://github.com/username/pan.dev.git

    Use this when you have not yet created a copy of the repo locally

  • git pull pulls changes from repository you cloned and merges them into their respective branches

    git pull

    Use this when you want to grab changes that have been pushed to the repo you are working on and bring them locally

  • git fetch reaches out to repository you cloned to ask if there are changes, does not merge them

    git fetch

    Use this to see if if there are changes without merging them

  • git merge merges branch-name into your working branch

    git merge `branch-name`

    Use this to get your repo in sync with another branch.

    caution this could result in a conflict, more on that later

Keep track of your work

  • git checkout checkout a branch or create a new branch and check it out

    git checkout -b branch-name

    Use this to switch branches or create a new branch off of your current branch

  • git branch see which branch you are working in and other available branches

    git branch

    Use this to keep track of where you are and which branches you have locally

  • git status see all files with changes you've made in your working branch

    git status

    Use this to see what changes have been made (whether on purpose or accident)

  • git add <filename> adds a file you've edited to be staged for a commit

    git add docs/contributing/git_basics

    Use git status to see which files have changed and git add to pull out only the files you want to commit. git add . will add all changed files.

    • git commit takes all staged files and bundles them into a commit
    git commit -m "summary of the commit"

    Use this to combine your changes and prepare to push for others

  • git push takes a commit and pushes it to the repository

    git push origin branch-name

    Use this to push the changes to the repository where you can share them with others or merge them into the main branch