git checkout -b __newbranch__: get a new branch and switch to itgit checkout -b __branchname__ / __branchname__: get a local copy of a remote existing branchgit checkout __branchname__: switch branchgit checkout --orphan __branchname__: create branch without full historygit log -n X -p: show X last commits with diffsgit log __branchA__ ^__branchB__: commits in branch A that aren't in branch Bgit log --pretty=oneline --stat --all __foldername__: modified files under a given foldergit fetchgit pull origin __branchname__git merge --no-ff __sourcebranch__: merge into current branch source one without rebase/FFgit push origin __destinationbranch__: push merges/changesets to a branchgit remote show origin: display the path of the repositorygit remote set-url origin xxx: Change remote URI to xxxgit remote rm origin: Remove remote URIgit remote add origin git@github.com:CartoDB/cartodb.js.git: Add remote URI (for example after adding SSH key withssh-add ~/.ssh/id_rsa). Must firstgit remote rm originto remove previous one.git add xxx: add files (use . for everything, folder/.. for folder recursive children)git commit: commit changesgit status: show status of uncommited filesgit checkout __file__: revert a filegit checkout __branchname__ __file__: Checkout all changes to file from branch branchname into currentgit checkout __revision__ .: revert a full branch to specified revision if not commitedgit revert __commit1__ __commit2__ ...: Reverts certain commits if commitedgit reset __revision__ .: revert a full branch to specified revision if commitedgit clean -f: remove all local uncommited modificationsgit branch: display local branches, active one is with a *git diff: Show changes in filesgit rebase __branchname__: rebases current branch with specified branch (fetches remote branch changes and then adds yours at the tip)git rm __filename__: delete a file from branch and filesystemgit branch -d __branchname__: delete a local branchgit push origin --delete __branchname__: delete a remote brachgitk __filename__: show visual git loggit reset --soft HEAD~1: reset to last commit (even if pushed). Can re-commit stuff but if already pushed will need to push with--force.git log origin/__branchname__..__branchname__: Show diff between local commits and remote commitsgit config --list: List currently setup config valuesgit config --global user.name "Kartones": Setup global user namegit config --global user.email "d...@....net": Setup global user emailgit config --global credential.helper 'cache --timeout=28800': Make git cache credentials for 8 hoursgit config --global color.ui true: Activate colors in diffs, etc.git config --global core.autocrlf true: Fix Convert newlines to Unix-style ones (Windows)git config --global core.autocrlf input: Fix Convert newlines to Unix-style ones (Unix)*git config --global pager.log 'diff-highlight | less': Better diff highlighting (same for 3 following options)git config --global pager.show 'diff-highlight | less'git config --global pager.diff 'diff-highlight | less'git config --global interactive.diffFilter diff-highlightgit submodule update --init --recursive: Init and update all submodulesgit submodule init && git submodule update: Retrieve and update all submodules (alt)- Switch from current branch having a submodule to a branch without it:
rm -Rf __submoduledir__
git reset && git checkout .
git checkout __branchname__git pull https://github.com/__username__/__reponame__.git __branchname__: Merge a pull request to local branchgit stash: Stash current changesgit stash apply: Unstash and merge stored changesgit checkout --theirs xxxxgit checkout --ours xxxx: Keep changes from incoming branch or local one, respectively.git blame -M: Blames original commit, not the move commitgit blame -CCC: Looks at all commits in historygit cherry-pick __commit__: merges and commits a specific commit to current branchgit reflog+git reset HEAD@__commit__: show all changes on all branches and revert to a specific onegit commit --amend: Squash a change on previous commit and change the commit messagegit diff --staged: Show both staged and unstaged changes that you will commit
- Issues in which you're mentioned
- Pull requests in which you're mentioned
- All open issues and pull requests of organization
TEST: Change to proper organization name, and for example can filter to all assigned to you
- tig: to navigate commits & branches
- Github:
- Commands for automatically closing tickets when merged to default branch
- Search to display all issues/PRs of an organization:
https://github.com/issues?utf8=%E2%9C%93&q=is%3Aopen+org%3Athemotion+sort%3Aupdated-desc- Additionally, filter to things assigned to me or involving me:
https://github.com/issues?utf8=%E2%9C%93&q=is%3Aopen+org%3Athemotion+sort%3Aupdated-desc+involves%3Akartones
- Atlassian Git tutorial
- Git Cookbook
- Most Common Git tips & tricks (awesome list)