-28,6 +28,68 |
* [http://stackoverflow.com/questions/12651749/git-push-fails-rpc-failed-result-22-http-code-411 git push fails: RPC failed; result=22, HTTP code = 411] |
* <code>git config http.postBuffer *bytes*</code> |
|
마지막 커밋 이후에 파일 하나에 생겨난 여러 수정 내역 중에 일부만 커밋하고 싶을 때 |
* 예를 들어 a.pl 파일에 새 기능을 추가하다가 다른 지점에서 버그를 발견해서 그것도 고쳤는데 버그 수정 부분만 먼저 커밋하고 싶은 경우 |
* <code>git add --patch</code> |
{{{ |
$ git diff |
diff --git a/develop.txt b/develop.txt |
+patch 1 <-- 요것만 커밋하고 싶다 |
develop branch 1 |
develop branch 2 |
+patch 2 <-- 요건 놔두고 |
|
$ git add --patch develop.txt <-- patch 옵션 |
@@ -1,2 +1,4 @@ |
+patch 1 |
develop branch 1 |
develop branch 2 |
+patch 2 |
Stage this hunk [y,n,q,a,d,/,s,e,?]? s <-- 한 덩어리에서 더 쪼개기 위해 's'plit |
Split into 2 hunks. |
@@ -1,2 +1,3 @@ |
+patch 1 |
develop branch 1 |
develop branch 2 |
Stage this hunk [y,n,q,a,d,/,j,J,g,e,?]? y <-- 내가 원하는 것만 인덱스에 올리고 |
@@ -1,2 +2,3 @@ |
develop branch 1 |
develop branch 2 |
+patch 2 |
Stage this hunk [y,n,q,a,d,/,K,g,e,?]? n <-- 이건 패스 |
|
$ git diff --cached |
@@ -1,2 +1,3 @@ |
+patch 1 <-- 인덱스에 이 줄만 올라왔다 |
develop branch 1 |
develop branch 2 |
}}} |
|
다른 브랜치에 있는 파일 하나만 가져오고 싶을 때 |
* A브랜치에서 작업 중인데, B브랜치에 있는 버전의(또는 B브랜치에만 있는) 파일을 가져오고 싶다. B브랜치를 체크아웃해서 파일을 다른 곳에 복사한 후 다시 A브랜치를 체크아웃해서 그 복사한 걸 가져오고... |
* <code>git checkout B file</code> |
|
로컬 브랜치와 리모트 브랜치 삭제 |
* [http://stackoverflow.com/questions/2003505/delete-a-git-branch-both-locally-and-remotely github - Delete a Git branch both locally and remotely - Stack Overflow] |
|
가장 최근에 발생한 여러 커밋을 일괄 취소하고 싶을 때 |
* [https://stackoverflow.com/questions/1463340/how-to-revert-multiple-git-commits How to revert multiple git commits?] |
|
특정 커밋 이전 히스토리를 지우고 싶을 때 (예를 들어 github에서 받은 프로젝트에 내가 이런 저런 커밋을 했는데 git log를 하면 원래 있던 커밋들도 와르르 나오니까 내가 받아온 시점을 첫 커밋으로 만들고 그 이전은 전부 삭제) |
* [https://passingcuriosity.com/2017/truncating-git-history/ Truncating git history] |
{{{#!vim |
# A커밋 이전의 커밋들을 삭제하고 싶음 |
$ git checkout --orphan temp A |
$ git commit -m "Truncate history" |
$ git rebase --onto temp A master |
}}} |
|
첫번째 커밋을 리셋하고 싶을 때 |
* https://stackoverflow.com/questions/6632191/how-to-revert-initial-git-commit |
* <code>git update-ref -d HEAD</code> |
|
|
|
== # 딱 부러진 해결책을 못 찾은 상태 == |
|
로컬 저장소에서 한 파일에 '특정한 변경' 부분만 따로 유지하되, 원격으로 push할 때 전달되지 않게 막고 싶은 경우: |