0

我使用 osx 的 git 客户端。

我对我的分支进行了一些更改。我不想犯这些。我怎样才能恢复到我最近提交的分支?

4

1 回答 1

1

I'm not sure which client you're talking about, unless it's the command-line client, but one of the following should set you up.

git reset --hard HEAD       # Which reverts your local branch to the last commit
git checkout -- [filename]  # Un-stages changes with have been added, but not yet committed
git checkout [commit hash] [filename] # Grabs the version from the commit specified by [hash]

The other possibility is that the changes haven't even been added yet, and that you don't have to do anything. If you want to keep those changes around for later, but do not with to commit them to the repository then you can do a:

git stash

All these commands' manuals should be available via:

man git-reset
man git-checkout
man git-stash
于 2013-09-06T15:22:38.153 回答