2013-07-10 4 views
2

일반적으로 작업 디렉토리가 깨끗하면 "git status"를 사용할 수 있습니다. 출력은 보이는 같은 :Git : 작업 디렉토리가 수정되었을 때 로컬 브랜치가 원격 브랜치보다 앞서 있는지 확인하는 방법은 무엇입니까?

# On branch master 
# Your branch is ahead of 'origin/master' by 1 commit. 
# 
nothing to commit (working directory clean) 

그러나, 작업 디렉토리가 변경되었을 경우, "자식 상태"출력 :

# On branch master 
# Changes not staged for commit: 
# (use "git add <file>..." to update what will be committed) 
# (use "git checkout -- <file>..." to discard changes in working directory) 
# 
#  modified: body/chap1.tex 
# 
no changes added to commit (use "git add" and/or "git commit -a") 

내가 원격 지사에 대한 모든 변경을 추진 한 경우 두 번째 결과가 표시되지 않습니다 . 때로는 작업 디렉토리가 수정 될 때 여전히 첫 번째 결과를 원합니다. 그런 상태에서 그것을 얻는 방법?

답변

1

이것은 준비 트리의 목적입니다. 이 후 커밋 작업 또는 미트되지 않은에서 (준비 트리에 별도 저장 될 수 있도록

git add path/to/your/file.php 

이 파일을 상연한다 : 당신이 다음에 당신이 커밋 다음의 repo에 보낼 작품을 무대에 수 작업), 미래 git status 호출하면 커밋되지 않은 작업과 별도로 준비한 작업이 표시됩니다. 이것은 git에서 표준적인 방법이며 커밋 할 내용을 추적 할 수있게 해줍니다. 스테이징은 선택적 커밋을 허용하는 방법이지만 서버는 용도를 결정해야합니다. 아마도 단순한는, 현재의 변화를 숨기고 확인 후 숨겨 놓은 팝업하는 것 http://git-scm.com/book/ch1-3.html

1

: 여기

더 잘 준비 영역을 설명하는 링크입니다. 따라서,

git stash 
git status 
git stash pop 

이것은 새로운 파일로 모든 변경, (git stash 그들을 숨겨 놓은하지 않기 때문에)에 대해 작동하지 않습니다. 그러나, 내가 문제를 재현하고 있지 않다 '라고해야 : 위에서

[email protected](14)$ git status 
# On branch master 
# Your branch is ahead of 'origin/master' by 1 commit. 
# 
nothing to commit (working directory clean) 
[email protected](15)$ ed .gitignore 
1165 
... 
q 
[email protected](16)$ git status 
# On branch master 
# Your branch is ahead of 'origin/master' by 1 commit. 
# 
# Changes not staged for commit: 
# (use "git add <file>..." to update what will be committed) 
# (use "git checkout -- <file>..." to discard changes in working directory) 
# 
# modified: .gitignore 
# 
no changes added to commit (use "git add" and/or "git commit -a") 

origin에 관련된 상태는 여전히 나타납니다. 그래도 제 제안은 작동합니다 :

[email protected](17)$ git stash 
Saved working directory and index state WIP on master: b541ae8 Ignore 'SPOT Lang*' files 
HEAD is now at b541ae8 Ignore 'SPOT Lang*' files 
[email protected](18)$ git status 
# On branch master 
# Your branch is ahead of 'origin/master' by 1 commit. 
# 
nothing to commit (working directory clean) 
[email protected](19)$ git stash pop 
# On branch master 
# Your branch is ahead of 'origin/master' by 1 commit. 
# 
# Changes not staged for commit: 
# (use "git add <file>..." to update what will be committed) 
# (use "git checkout -- <file>..." to discard changes in working directory) 
# 
# modified: .gitignore 
# 
no changes added to commit (use "git add" and/or "git commit -a") 
Dropped refs/[email protected]{0} (8ff02f7a27053ca7680b0a98048542fcbe2bb440) 
+0

Windows 시스템에서는 msys-git을 사용하고 있습니다. 그것은 조금 다릅니다. – river6