-
Git - 수정하고 저장소에 저장하기
-
이 benchmarks.rb
파일은 Changes not staged for commit
에 있다. 이것은 수정한 파일이 Tracked 상태이지만 아직 Staged 상태는 아니라는 것이다. Staged 상태로 만들려면 git add
명령을 실행해야 한다. git add
는 파일을 새로 추적할 때도 사용하고 수정한 파일을 Staged 상태로 만들 때도 사용한다. git add
를 실행하여 benchmarks.rb 파일을 Staged 상태로 만들고 git status
명령으로 결과를 확인해보자:
-
헉! benchmarks.rb가 Staged 상태이면서 동시에 Unstaged 상태로 나온다. 어떻게 이런 일이 가능할까? git add
명령을 실행하면 Git은 파일을 바로 Staged 상태로 만든다. 지금 이 시점에서 커밋을 하면 git commit
명령을 실행하는 시점의 버전이 커밋되는 것이 아니라 마지막으로 git add
명령을 실행했을 때의 버전이 커밋된다. 그러니까 git add
명령을 실행한 후에 또 파일을 수정하면 git add
명령을 다시 실행해서 최신 버전을 Staged 상태로 만들어야 한다:
-
-
이 명령은 워킹 디렉토리에 있는 것과 Staging Area에 있는 것을 비교한다. 그래서 수정하고 아직 Stage하지 않은 것을 보여준다.
-
git diff
명령은 마지막으로 커밋한 후에 수정한 것들 전부를 보여주지 않는다. git diff
는 Unstaged 상태인 것들만 보여준다.
-
git diff
명령으로 Unstaged 상태인 변경 부분을 확인해 볼 수 있다:
-
Staged 상태인 파일은 git diff --cached
옵션으로 확인한다:
-
git rm
명령을 실행하면 삭제한 파일은 staged 상태가 된다:
-
또 Staging Area에서만 제거하고 워킹 디렉토리에 있는 파일은 지우지 않고 남겨둘 수 있다. 다시 말해서 하드디스크에 있는 파일은 그대로 두고 Git만 추적하지 않게 한다. 이것은 .gitignore
파일에 추가하는 것을 빼먹었거나 대용량 로그 파일이나 컴파일된 파일인 .a
파일 같은 것을 실수로 추가했을 때 쓴다. --cached
옵션을 사용하여 명령을 실행한다:
-
$ git rm --cached readme.txt
-
Elixir's With Statement
-
Every statement of with
is executed in order. Execution continues as long as left <- right
match. As soon as a match fails, the else
block is executed.
-
If all statements match, the do
block is executed and has access to all the local variables in the with
block.
-
If we didn't return {:ok, X}
, our match would look like:
-
However, a
variable on the left side matches everything. In other words, the above would treat the
{:error, "BLAH"}
as matches and continue down the "success" path.
Posted from Diigo. The rest of my favorite links are here.
댓글