commit 하기 전에 'git add' 한것을 되돌리는 방법.
Q. How do I undo 'git add' before commit?
Q. commit 하기 전에 'git add' 한거 뒤로 돌리려면 어떻게 해야 하나요?
I mistakenly added files to Git using the command:
제가 실수로 아래의 커맨드를 써서 파일을 Git 에 add 했습니다.
git add myfile.txt
I have not yet run git commit
. Is there a way to undo this, so these files won't be included in the commit?
아직 git commit
을 배운진 않았습니다. 커밋에 이 파일이 포함되지 않도록 되돌리는 방법이 있나요??
You can undo git add
before commit with
사용자는 git add
로 추가한 파일을 커밋 하기 전에 git reset
을 써서 되돌릴 수 있습니다.
git reset <file>
which will remove it from the current index (the "about to be committed" list) without changing anything else.
다른것은 바꾸지 않고 현재 가리키고 있는 index를 삭제합니다.
You can use
사용자는 git reset
을 이용해서
git reset
without any file name to unstage all due changes.
되돌릴 파일에 대한 이름 없이도 수행이 가능합니다.
This can come in handy when there are too many files to be listed one by one in a reasonable amount of time.
이것은 너무 많이 파일이 있어 하나씩 적기 힘들 때 매우 유용합니다.
In old versions of Git, the above commands are equivalent to git reset HEAD
and git reset HEAD
respectively, and will fail if HEAD
is undefined (because you haven't yet made any commits in your repository) or ambiguous (because you created a branch called HEAD
, which is a stupid thing that you shouldn't do).
옛날 버전에서 위의 커맨드는 git reset HEAD
, git reset HEAD
과 비슷합니다. 그리고 HEAD
가 정의되지 않거나, 애매모호 할 경우엔 실행되지 않을 겁니다.
This was changed in Git 1.8.2, though, so in modern versions of Git you can use the commands above even prior to making your first commit:
이것은 Git 1.8.2에서 패치 되었는데, 인제는 위의 커맨드를 첫 커밋을 생성하기 전에도 이용할 수 있습니다.
"git reset" (without options or parameters) used to error out when you do not have any commits in your history, but it now gives you an empty index (to match non-existent commit you are not even on).
과거에는 "git reset"을 이용할 때 과거에 커밋 한 적이 없으면 에러를 표시했습니다. 지금의 경우엔 그저 빈 index를 반환 할 뿐입니다.
ambigous : 애매모호한
defined : 정의된
Author And Source
이 문제에 관하여(commit 하기 전에 'git add' 한것을 되돌리는 방법.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@jsin2475/commit-하기-전에-git-add-한것을-되돌리는-방법저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)