I have a git repository with some commits in it. I want to reproduce exact state of working directory as it was right after specific commit (Here i suppose that i ve commited all changes that were made).
我尝试使用<代码>git 核对,但该指令没有删除工作名录中的现有档案(在预留之后添加)。
说明我问题的简单例子。 我利用以下指挥系统编制了存放处。
u@u-desktop:/tmp/git$ git init
Initialized empty Git repository in /tmp/git/.git/
u@u-desktop:/tmp/git$ echo ffff > first.file
u@u-desktop:/tmp/git$ git add first.file
u@u-desktop:/tmp/git$ git commit -m "Important file was added"
[master (root-commit) fb05f7e] Important file was added
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 first.file
u@u-desktop:/tmp/git$ echo Second line >> first.file
u@u-desktop:/tmp/git$ git commit -m "Important data was added" -a
[master df93d04] Important data was added
1 files changed, 1 insertions(+), 0 deletions(-)
u@u-desktop:/tmp/git$ echo ssss > second.file
u@u-desktop:/tmp/git$ git add second.file
u@u-desktop:/tmp/git$ git commit -m "Second important file was added"
[master b6c106a] Second important file was added
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 second.file
u@u-desktop:/tmp/git$ echo tttt > third.file
u@u-desktop:/tmp/git$ git add third.file
u@u-desktop:/tmp/git$ git commit -m "Third important file was added"
[master 33fce06] Third important file was added
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 third.file
现在的名录看着这一点。
u@u-desktop:/tmp/git$ ls
first.file second.file third.file
www.un.org/spanish/ga/president 内容如下:
u@u-desktop:/tmp/git$ cat first.file
ffff
Second line
Now i want restore working directory as it looked right after first commit (fb05f7e
)
u@u-desktop:/tmp/git$ git checkout fb05f7e .
u@u-desktop:/tmp/git$ cat first.file
ffff
但second.file
and third.file
are still in the summary.
u@u-desktop:/tmp/git$ ls
first.file second.file third.file