git add -p
git checkout -- <path>
The parameter path
can be equal .
to discard all the changes.
git add [-A] [<path>]
git reset <path>
If no path
is provided, all the changes are staged.
The parameter -A
means:
Update the index not only where the working tree has a file matching but also where the index already has an entry. This adds, modifies, and removes index entries to match the working tree.
git add -p
git diff --staged
More information about this one can be found on Stack Overflow.
git fetch <remote> [<branch>]
As long as you're doing a fast-forward merge, then you can simply use:
git fetch <remote> <sourceBranch>:<destinationBranch>
Source on Stack Overflow.
git merge <branch>
git pull [<repo>] [<branch>]
A git pull
operation is equal to a git fetch
followed by a git merge
. If the local branch contains non pushed commits, the command creates an intermediate commit that performs the merge operation.
git pull --rebase <repo> <branch>
Similar to git pull
, but rebase the branch before applying the remote commits. In other words, the local branch will apply the remote commits before applying the local commits. Thus, this prevents creating an intermediate commit.
git push [<repo>] [<branch>]
If the branch name is not provided, the global configuration push.default
is used to determine the branches to push. More information about the value of this paramater can be found on (Stack Overflow)[http://stackoverflow.com/a/21866819/2780334].
git push --tags
git push <repo> <branch>:<branch>
It's possible to have multiple <branch>:<branch>
declarations in a same command.
git branch
git branch -r
git branch <branch>
git branch -d <branch>
git push origin --delete <branch>
git checkout <branch>
git push <remote> --all
git log (--oneline) <branch>
git log (--oneline) master..origin/master
git stash save <message>
git stash show <name>
git stash pop [<name>]
git stash apply [<name>]
git stash drop [<name>]
git rebase -i HEAD~<n>
Interactively rebase the branch on <n>
commits en enable the user to keep/squash/edit/delete them.
git revert <sha>
Where <sha>
is the identifier of the commit to revert.
git diff
git diff -- . ':!*.css' ':!*.scss'
Where we ignore *.css
and *.scss
extensions. More information on StackOverflow.
git lg
Use this utility available on Github. To install it, run the following command:
wget -P /usr/local/bin/ https://raw.githubusercontent.com/bill-auger/git-branch-status/master/git-branch-status
The documentation can be found on Github.
Set the Windows PATH with the folder of Beyond Compare, e.g. C:\Program Files\Beyond Compare 4
.
Set it as the default difftool/mergetool:
git config --global diff.tool bc3
git config --global difftool.bc3.trustExitCode true
git config --global difftool.bc3.cmd "\"bcomp.exe\" \"\$(cygpath -w \$LOCAL)\" \"\$REMOTE\""
git config --global merge.tool bc3
git config --global mergetool.bc3.trustExitCode true
git config --global diff.tool bc
git config --global difftool.bc.trustExitCode true
git config --global difftool.bc.cmd "\"bcomp.exe\" \"\$LOCAL\" \"\$REMOTE\""
git config --global merge.tool bc
git config --global mergetool.bc.trustExitCode true
git config --global mergetool.bc.cmd "\"BComp.exe\" \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\""
# Disable git status in the prompt
git config --add oh-my-zsh.hide-status 1
# Disable the tracking of dirty files
git config --add oh-my-zsh.hide-dirty 1
References on SO and on marc-abramowitz.com.
Add the code below in .zshrc.
__git_files () {
_wanted files expl 'local files' _files
}
Reference on SO.