📜  取消跟踪本地更改 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:12.906000             🧑  作者: Mango

代码示例1
If you want remove all local changes - including files that are untracked by git - from your working copy, simply stash them:

git stash push --include-untracked
If you don't need them anymore, you now can drop that stash:

git stash drop
If you don't want to stash changes that you already staged - e.g. with git add - then add the option --keep-index. Note however, that this will still prevent merging if those staged changes collide with the ones from upstream.

If you want to overwrite only specific parts of your local changes, there are two possibilities:

Commit everything you don't want to overwrite and use the method above for the rest.

Use git checkout path/to/file/to/revert for the changes you wish to overwrite. Make sure that file is not staged via git reset HEAD path/to/file/to/revert.