|** what** |**cmd ** |** comments** | |add all files |git add . |  | |add only modified files and ignore untracked files | git add -u |  | |remove a file |git remove | also deletes from filesystem. If you wish to leave in file system use git rm --cached file.txt | |show changes |git status | use "git status -uno" to not show untracked files | |commit changes |git commit -m 'comment' |  | |upload changes |git push origin master | use the -u flag on first push i.e. git push -u origin master. And it may be the case you only need "git push" after the first push? See http:%%//%%stackoverflow.com/questions/6089294/why-do-i-need-to-do-set-upstream-all-the-time| | replace master branch with new brunch | git push -u -f origin master | the -f is the magic | | commit all changed files | git commit -a -m 'message' | you have to put the message in, apparently | | pull and overwrite untracked files |git fetch --all\\\\ git reset --hard origin/master | from [[http://stackoverflow.com/questions/1125968/force-git-to-overwrite-local-files-on-pull|here]] | | create new branch | git branch |  | | switch to branch |git checkout   |  | | start a new branch with uncommitted changes | git checkout -b new_branch\\\\ git add . | use when you forget to start a new branch before editing code | |list names of remote branches |git branch -r |  | | create local branch that tracks remote branch | git branch |  | | reset local with remote head | git reset --hard origin/ |  | |  |  |  | | merge branch (named test in this example)  with master | git checkout master\\\\ git pull origin master\\\\ git merge test\\\\ git push origin master\\|  | |show changes of the last 2 commits. |git log -p -2 |  | |Do this before you pull to show what commits you are about to retrieve, along with the names of the files.\\|  git fetch git log --name-status origin/master.. |  | |add symbolic reference (alias) | git symbolic-ref refs/heads/stable refs/heads/v1.2.24 |in this example stable will point to v1.2.24 | | list all tags and show date of tag | git log --tags --simplify-by-decoration --pretty="format:%ai %d" |  | |Update the local list of remote branches |git remote update origin --prune |  | | checkout remote branch and create new local branch w/ same name as remove |git checkout --track origin/ |  | |clone git into current (and non-empty) directory | git init .\\\\ git remote add origin \\\\ git pull origin master | from https:%%//%%stackoverflow.com/questions/9864728/how-to-get-git-to-clone-into-current-directory | \\ * [[http://jondavidjohn.com/git-pull-from-a-php-script-not-so-simple/|doing an automatic git pull (webhook) from a php script]] * [[https://github.com/TeamPorcupine/ProjectPorcupine/wiki/How-to-Test-a-Pull-Request|how to test a PR]] * clone all remote branches as local branches: ''git branch -a | grep -v HEAD | perl -ne 'chomp($_); s|^\*?\s*||; if (m|(.+)/(.+)| && not $d{$2}) {print qq(git branch --track $2 $1/$2\n)} else {$d{$_}=1}' | csh -xfs'' (from [[https://stackoverflow.com/questions/67699/how-do-i-clone-all-remote-branches]])