어떻게 돌아가는 마지막 commit 역사에서 사용 후 git 다시 설정하는 오래된 집?

StackOverflow https://stackoverflow.com/questions/2540505

  •  23-09-2019
  •  | 
  •  

문제

가정 내가는 방법:

A-B-C-D(master)

내가 할 경우 git reset B, 겠어:

A-B(master)

는 문제입 git log 지금 보는 나만의 역사에서,그리고 나는 볼 수 없는 C 및 D 더 이상입니다.

는 방법으로 돌아갈 수 있 D?

도움이 되었습니까?

해결책

You should be able to see D with git reflog.

See this article for instance.

The only time commits are actually deleted is if you git gc --prune (so be careful with that one!).

If you run git reflog right now in a repository you’ve been working in, you’ll see lots of changes that look something like this:

c5c3a82... HEAD@{0}: pull origin featureB: Merge made by recursive.
49d0608... HEAD@{1}: reset --hard HEAD^: updating HEAD
3ed01b1... HEAD@{2}: pull origin featureA: Merge made by recursive.
49d0608... HEAD@{3}: pull origin bugfixJ: Merge made by recursive.
854d44e... HEAD@{4}: commit: Add more cowbell to foo.c
6dbc22d... HEAD@{5}: pull origin bugfixI: Merge made by recursive.
9bdb763... HEAD@{6}: commit: Remove weevils
8518f9d... HEAD@{7}: checkout: moving from wickedfeature to master

These lines can be broken down into 4 parts:

  • commit hash,
  • commit pointer,
  • action,
  • and extra info.

If we wanted to get back the commit that was lost at HEAD@{1}, we could just git reset --hard HEAD@{2}.
Now our current branch (and working copy) are set to the repository state before we did the reset.

If we wanted to just see what that state was, we could git checkout -b temp HEAD@{2} (or git checkout HEAD@{2} if you have git 1.5.0 and up).

다른 팁

Ok,그것을 발견했습니다.

당신이 사용할 수 있는 git reflog.

나는 그것이 무엇인지 몰랐었지만 지금은 볼 수있는 그것은 로그의 모든 참 머리되었을 가리키는.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top