git branch 만들고 merge하고 윈도우 + linux에서 이거저거 동시에 하다보니 뭔가 꼬인듯

아마 여러명이서 개발할 때 충분히 가능한 상황

a파일을 1번 컴터에서 수정했는데 이미 2번 컴터에서 수정해서 커밋, 푸쉬까지 완료

1번 컴터의 소스들을 날릴 수도 없고(pull), 그렇다고 푸쉬할 수도 없다


*** 오류 상황

> git pull

There is no tracking information for the current branch.

Please specify which branch you want to merge with.

See git-pull(1) for details

    git pull <remote> <branch>


If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master


> git revert source.c

fatal: bad revision 'source.c'


*** 해결 단계 #1

> git stash 

Saved working directory and index state WIP on master: 8d8f07c 어쩌고 저쩌고 커밋 주석들

HEAD is now at 8d8f07c 커밋 주석들

잠시 인벤에 넣어둘 수 있는 기능이라칸다


> git stash show

source.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)


> git pull

Updating 8d8f07c..62acd07

+-+_+_+_+_

pull이 된다, 2번 컴터로 작업한 데이터가 고스란히 복구 되었다




*** 오류 상황

> git stash pop

Auto-merging source.c

CONFLICT (content): Merge conflict in source.c

인벤에 넣어뒀던 파일이 튀어나오고 오토머징 된다

복구 해놨더니 stash pop 해서 파일이 1번 작업물과 2번 작업물이 섞였다


> git diff source.c

diff --cc source.c

index 5f69b98,f54d53e..0000000

--- a/source.c

+++ b/source.c

@@@ -1,6 -1,11 +1,17 @@@

++<<<<<<< Updated upstream

 +/**

 + *@file doxygen 주석들

 + */

++=======

+ /*

바뀐 내용들 

+ */

++>>>>>>> Stashed changes

이렇게 stash 이전/이후로 나눠서 파일에 같이 merge 되어 있다

직접 vi로 편집해도 되지만 웬지 싫었다

원복하고 싶었다



> git stash clear

일단은 주머니 초기화


*** 해결 단계 #2

> git reset HEAD source.c

Unstaged changes after reset:

M source.c


> git diff source.c

fatal: ambiguous argument 'source.c': unknown revision or path not in the working tree.

Use '--' to separate paths from revisions, like this:

'git <command> [<revision>...] -- [<file>...]'

맛감


> git checkout source.c

성공


2번 컴터로 올린 자료로 복구 되었다

Posted by 쵸코케키

블로그 이미지
chocokeki
쵸코케키

공지사항

Yesterday
Today
Total

달력

 « |  » 2024.4
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

최근에 올라온 글

최근에 달린 댓글

글 보관함