GIT usage
! Єдиний аспект для уточнення GIT вимовляється гіт, а не джіт.
git diff
compares the (i)ndex and the (w)ork tree;
git diff HEAD
compares a (c)ommit and the (w)ork tree;
git diff --cached
compares a (c)ommit and the (i)ndex;
git diff HEAD:file1 file2
compares an (o)bject and a (w)ork tree entity;
git diff --no-index a b
compares two non-git things (1) and (2).
http://ndpsoftware.com/git-cheatsheet.html#loc=workspace;
https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging
git-restore
git-restore is a tool to revert non-commited changes. Non-commited changes are:
a) changes in your working copy, or b) content in your index (a.k.a. staging area).
git-restore can be used in three different modes, depending on whether you like to
revert work in the working copy, in the index, or both.
git restore [--worktree] <file> overwrites <file> in your working copy
with the contents in your index. In other words, it reverts your changes
in the working copy. Whether you specify --worktree or not does not matter
because it is implied if you don't say otherwise.
git restore --staged <file> overwrites <file> in your index with the current HEAD
from the local repository. In other words, it unstages previously staged content.
It is indeed equivalent to the old git reset HEAD <file>.
To overwrite both, the working copy and the index with the current HEAD, use:
git restore --staged --worktree --source HEAD <file>.
This version does both: revert your working copy to HEAD and
unstage previously staged work.
What's the difference between git-restore and git-reset?
Both can be used to modify your working copy and/or the staging area.
However, only git-reset can modify your repository.
In this sense, git-restore seems the safer option if you only want to revert local work.
This form resets the current branch head to <commit>
and possibly updates the index (resetting it to the tree of <commit>
) and the working tree depending on <mode>
. If <mode>
is omitted, defaults to --mixed
. The <mode>
must be one of the following:
- --soft
Does not touch the index file or the working tree at all (but resets the head to
<commit>
, just like all modes do). This leaves all your changed files "Changes to be committed", asgit status
would put it.- --mixed
Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated. This is the default action.
- --hard
Resets the index and working tree. Any changes to tracked files in the working tree since
<commit>
are discarded. Any untracked files or directories in the way of writing any tracked files are simply deleted.git reset --soft HEAD~3
git log --all --decorate --oneline --graph
View remote branches
git remote -v
Comments
Post a Comment