我更新了cocoapods后,我项目中的某些文件发生了变化。我使用bitbucket来保持我的变化。现在,我想将之前的提交(带有id)下载到不同的目录,只需复制/粘贴必要的文件。而且我不希望下载影响git上的任何内容(直到我复制/粘贴文件)。首先我git clone
项目到另一个文件夹。
现在,我遇到了
git reset --hard
& git reset --soft
我无法获得主要的差异。我应该使用哪一个?
答案 0 :(得分:0)
来自man git
:
git reset [<mode>] [<commit>]
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", as git 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.
If -N is specified, removed paths are marked as intent-to-add (see git-add(1)).
--hard
Resets the index and working tree. Any changes to tracked files in the working tree since <commit> are discarded.
--merge
Resets the index and updates the files in the working tree that are different between <commit> and HEAD, but keeps those which are different between the index and working tree (i.e. which have
changes which have not been added). If a file that is different between <commit> and the index has unstaged changes, reset is aborted.
In other words, --merge does something like a git read-tree -u -m <commit>, but carries forward unmerged index entries.
--keep
Resets index entries and updates files in the working tree that are different between <commit> and HEAD. If a file that is different between <commit> and HEAD has local changes, reset is aborted.
所以区别在于--hard会丢弃对Git控制下的文件的任何本地更改。另一方面--soft只使符号引用HEAD指向较早的提交ID。