git
egoing edited this page Jun 8, 2022
·
43 revisions
이곳으로 오는 주소 ⇨ http://bit.ly/git-offline
- git : https://git-scm.com/ (git 설치 프로그램, 깃이 설치되는 경로를 변경하지 말아주세요)
맥에서는 터미널을 열고 git 명령어를 입력하면 자동으로 설치가 됩니다. - vscode : https://code.visualstudio.com/ (코드 에디터 프로그램, 포터블 버전은 사용하지 말아주세요) (설치 방법 영상 소개 : https://youtu.be/HKeB8oRto_I)
- kdiff3 : http://kdiff3.sourceforge.net/ (비교 프로그램)
- snipaste : https://www.snipaste.com/ (스크린캡처 프로그램. 선택사항)
- sourcetree : https://www.sourcetreeapp.com/ 설치할 때 Registration 항목에서 bitbucket server 말고 bitbucket을 선택해주세요. bitbucket에 회원가입을 해야 설치할 수 있습니다. 인터넷 익스플로어와 같이 오래된 브라우저에서는 설치가 안되는 경우가 있습니다.크롬을 이용해주세요. (깃 클라이언트. 강사가 설치를 요청할 때 설치해주세요.)
설정방법
git config --global --add merge.tool kdiff3
git config --global --add mergetool.kdiff3.path "C:/Program Files/KDiff3/kdiff3.exe"
git config --global --add mergetool.kdiff3.trustExitCode false
git config --global --add diff.guitool kdiff3
git config --global --add difftool.kdiff3.path "C:/Program Files/KDiff3/kdiff3.exe"
git config --global --add difftool.kdiff3.trustExitCode false
git config --global --add merge.tool kdiff3
git config --global --add mergetool.kdiff3.path /Applications/kdiff3.app/Contents/MacOS/kdiff3
git config --global --add mergetool.kdiff3.trustExitCode false
git config --global --add diff.guitool kdiff3
git config --global --add difftool.kdiff3.path /Applications/kdiff3.app/Contents/MacOS/kdiff3
git config --global --add difftool.kdiff3.trustExitCode false
git config --global diff.tool p4merge
git config --global difftool.p4merge.path 'C:\Program Files\Perforce\p4merge.exe'
git config --global merge.tool p4merge
git config --global mergetool.p4merge.path 'C:\Program Files\Perforce\p4merge.exe'
한글이 깨지는 경우 : Configure > Regional Settings > File Encoding for A > "UTF-8 BOM"
으로 변경
menu>install command line tools 실행 후
git config --global diff.tool bc3
git config --global merge.tool bc3
git config --global mergetool.bc3.trustExitCode true
- git commit 명령을 입력했을 때 아래와 같은 오류가 나온다면
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address
아래와 같이 자신의 이름과 이메일을 git에게 알려주시면 됩니다. 버전을 생성할 때 자동으로 사용할 이름과 이메일을 설정하는 화면입니다.
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
- https://docs.google.com/spreadsheets/d/19YyV5CqNCZDzrkJI6H0FNhkR4AOwh-r0CcwSZBP1hhM/edit?usp=sharing
- git 온라인 강의 입구 : https://opentutorials.org/module/3733
- 지식지도 : https://seomal.org
- gerrit : https://www.youtube.com/watch?v=Jv3ggQw7Eio
https://www.atlassian.com/git/tutorials/atlassian-git-cheatsheet
git config --global core.editor "code --wait"
git config --global core.editor "nano"
- 프로젝트 폴더를 만든다.
- 폴더를 저장소로 지정한다. (git init)
- 파일을 수정한다.
- 커밋에 포함시키고 싶은 파일을 스테이지로 등록한다. (git add)
- 커밋한다. (git commit)
- 시간 여행을 해본다 (HEAD를 옮긴다. => git checkout)
- 시간 여행을 끝낸다. (git checkout master)
- 버전을 취소한다. (master를 옮긴다. => git reset --hard )
- 버전을 복구한다. (작업 내역을 조회한다. => git reflog)
- 실험적인 작업을 시작하기 위해서 브랜치를 만든다(git branch exp)
- 실험적인 작업 브랜치에서 커밋한다. (git checkout exp)
- 마스터에서 작업을 한다. (git checkout master)
- 마스터로 실험을 병합한다. (git checkout master && git merge exp)
- 충돌 상황을 만들어 본다. (3 way merge의 개념을 활용한다)
- 원격 저장소를 만든다. (github.com, gitlab.com)
- 지역 저장소에 원격 저장소를 연결한다. (git remote add origin 원격 저장소의 주소)
- 지역 저장소의 비밀번호를 원격 저장소에 등록한다. (ssh-keygen, id_rsa.pub 파일을 github의 계정에 ssh 키로 등록한다)
- 지역 저장소의 브랜치와 원격 저장소의 브랜치를 연결한다. (git push -u origin master)
- 동료를 추가한다. (github의 setting의 collaborators에 동료의 계정을 추가한다)
- 충돌 상황을 만들어본다.
for i in {a..f} ; do echo $i > $i.txt; git add $i.txt; git commit -m "$i"; done;
for i in {a..f} ; do echo $i > foo.txt; git add foo.txt; git commit -m "$i"; done;
git init conflict
cd conflict
echo "1
-
-
2
-
-
3
-
-
4" > work.txt;
git add work.txt;
git commit -am "start";
git checkout -b exp
echo "1
-
-
E2
-
-
3
-
-
4" > work.txt
git commit -am "E2";
echo "1
-
-
E2
-
-
3
-
-
E4" > work.txt
git commit -am "E4";
git checkout master;
git checkout -b master;
echo "1
-
-
2
-
-
M3
-
-
4" > work.txt;
git commit -am "M3";
echo "1
-
-
2
-
-
M3
-
-
M4" > work.txt;
git commit -am "M4";
https://www.icloud.com/keynote/0L29YPsBkbTRSfiPWtT1rl6fg#keynote_2
git checkout master;
echo "1
-
-
2
-
-
3
-
-
4" > work.txt;
git add work.txt;
git commit -am "start";
git branch -D left;
git checkout -b left
echo "1
-
-
L2
-
-
3
-
-
4" > work.txt
git commit -am "L2";
echo "1
-
-
L2
-
-
3
-
-
L4" > work.txt
git commit -am "L4";
git checkout master;
git branch -D right;
git checkout -b right;
echo "1
-
-
2
-
-
R3
-
-
4" > work.txt;
git commit -am "R3";
echo "1
-
-
2
-
-
R3
-
-
R4" > work.txt;
git commit -am "R4";
echo "1
-
-
2
-
-
R3
-
-
R45" > work.txt;
git commit -am "R5";
git checkout right;
git rebase left;
git checkout left;
git merge right;
git init;
echo "1\n\n2\n\n3\n\n4" > revert.txt;
git add revert.txt;
git commit -m "init";
echo "m1\n\n2\n\n3\n\n4" > revert.txt;
git commit -am "m1";
echo "m1\n\nm2\n\n3\n\n4" > revert.txt;
git commit -am "m2";
echo "m1\n\nm2\n\nm3\n\n4" > revert.txt;
git commit -am "m3";
echo "m1\n\nm2\n\nm3\n\nm4" > revert.txt;
git commit -am "m4";
git revert HEAD@{2}
git init;
echo "" > revert.txt;
git add revert.txt;
git commit -m "init";
echo "1" > revert.txt;
git commit -am "1";
echo "2" > revert.txt;
git commit -am "2";
echo "3" > revert.txt;
git commit -am "3";
echo "4" > revert.txt;
git commit -am "4";
git revert HEAD@{2};
# 1 - 2 - 4
https://github.com/egoingsb/git-linear-binary-compare.git
echo "1 linearsearch unhappy bug" >> foo.txt ; git add foo.txt; git commit -m 1;
for i in {2..125} ; do echo $i >> foo.txt; git add foo.txt; git commit -m "$i"; done;
echo "126 binary search bug" >> foo.txt ; git add foo.txt; git commit -m 126;
for i in {127..199} ; do echo $i >> foo.txt; git add foo.txt; git commit -m "$i"; done;
echo "200 linear search happy bug" >> foo.txt ; git add foo.txt; git commit -m 200;
- git bisect start
- git bisect bad
- git bisect good 문제가 없는 커밋 아이디
- git bisect good과 bad를 반복한다.
- good과 bad가 같은 커밋을 가리키면 bisect 탐색 작업이 끝난다.
- git bisect reset
- 버그를 수정하고 커밋한다.
https://gist.github.com/egoing/612bb75f2bca99cd1b377074c369c495
- git submodule status : 디렉토리에 연결된 마지막 버전을 알려준다.
- git submodule summary : 디렉토리에 연결된 마지막 버전과 현재 버전이 다를 때 그 차이를 보여준다.
- git submodule init ... 을 통해서 선택적으로 동기화 할 수 있다.