로컬과 원격저장소
- # git remote(-v)
- remote repository에 조회하기
- # git init --bare remote
- 로컬에 원격 저장소 생성
- 로컬 remote 저장소
- git remote add origin ssh://[remote저장소 username]@[remote저장소 IP]/저장소 path
- # git remote add origin ssh://git@{192.168.1.10}/home/git/remote/
- git remote add origin ssh://[remote저장소 username]@[remote저장소 IP]/저장소 path
- # git remote add origin https://github.com/fastwon1/jaon.git
- 원격저장소 URL을 origin이라는 이름으로 추가
- # git push origin master
- origin에 master 브랜치의 내용을 push
- remote repository에 밀어넣기
- # git pull origin master
- origin을 내 repository의 master 브랜치로 download / merge
- 현재 내가 작업하고 있는 내용은 사라짐
- # git fetch origin master
- 동기화시키지 말고 origin을 내 repository의 master 브랜치로 가지고옴(원격저장소로부터 파일만 다운로드 받음)
- 장점
- 지역저장소와 원격저장소간의 diff를 확인할 수 있음
- # git diff HEAD origin/master
- fetch 내용을 특정 브랜치에서 확인할 수 있다
- # git checkout origin/master
- # git checkout FETCH_HEAD
- 장점
- 동기화시키지 말고 origin을 내 repository의 master 브랜치로 가지고옴(원격저장소로부터 파일만 다운로드 받음)
- # git clone
- remote repository의 내용을 현재 디렉토리에 복사
- origin이라는 remote repository가 자동으로 등록된다
협업
- local repository의 변경사항이 있는데 remote repository는 변경이 없는경우
- git push로 해결
- local repository는 변경사항이 없는데 remote repository가 변경사항이 경우
- git pull로 동기화 후 push
- local repository도 변하고 remote repository도 변한 경우
- pull request
- 협업 대상 repository fork하기
- fork 해온 곳에서 clone 하기
- branch를 만들고 작성하고자하는 코드 commit 작성
- push 권한주기(Manage access(collaborator) 추가하기) 또는 pull request 요청
- 해당 branch 삭제
- merge
- fast-forward merge
- 3-way merge
- merge의 결과인 새로운 merge commit이 생성
- rebase
- 현재 작업하고 있는 branch의 base를 옮김
- base = 현재 작업하고 있는 branch와 합치려는 branch의 공통조상
- 병합하고자 하는 master branch의 최신 commit으로 base를 옮김
- 현재 작업하고 있는 branch의 base를 옮김
- pull request
Troubleshooting)
- github에 처음 push하려고 할때 아래와 같음 error 발생시
- remote: Permission to ~~~~~
- git push https://[아이디]:[비밀번호]@github.com/[아이디]/[레포지토리].git
| 아이디: not-working 비번: 123456 repository: test -> git push https://not-working:123456@github.com/not-working/test.git |
Set up Git - GitHub Docs
To use Git on the command line, you'll need to download, install, and configure Git on your computer. You can also install GitHub CLI to use GitHub from the command line. For more information on GitHub CLI, see the GitHub CLI documentation. If you want to
docs.github.com
[141] 오픈소스를 쓰려는 자, 리베이스의 무게를 견뎌라
오픈소스를 쓰려는 자, 리베이스의 무게를 견뎌라
www.slideshare.net
'기타 > git' 카테고리의 다른 글
| git tag (0) | 2021.07.23 |
|---|---|
| git stash (0) | 2021.07.16 |
| gistory .git 디렉토리 분석 (0) | 2021.07.11 |
| git 기본 명렁어 (0) | 2021.07.11 |
| git/github 설치 및 초기화 (0) | 2021.01.21 |