[PROJECT] TIL 042 - 23.09.12

유진·2023년 9월 12일
0

Semi Project

BRANCH

  • main 코드 변화를 주지 않음 : 마지막 배포 시에 main으로 감

  • main(메인 브랜치) -> development(개발 브랜치) -> 팀원1, 팀원2, 팀원3

** development :
팀원1, 팀원2, 팀원3 -> development(개발 브랜치)
Pull requests(PR) 팀원들의 코드를 병합하는 과정 -> (Merge : 병합)


(조장)
1. gitHub -> new -> 새로운 레파지토리 생성

2. 원하는 파일 경로에 git 주소 붙여넣기

3. Settings 클릭 -> Collaborators 사람들 초대하기 -> Add people

4. 사람들 email 추가

5. 사람들이 email 초대 주소 받으면 성공!

development 생성할 때

git checkout -b development

없던 것을 생성하면서 기존에 있던 브랜치 밑으로 main과 같은 레벨로 이동하는 것
(Switched to a new branch 'development')
git branch
현재 레파지토리에 있는 git branch 목록이 나옴, *는 현재 브랜치

git branch -a
(remotes/origin/main) : 원격 레파지토리에는 main만 있다.

git push --all : 모든 레파지토리를 원격 저장소로 push하는 문구


(팀원)

폴더 하나 새로 생성
git bash 열어 git clone 주소 -> 복사해 넣기.

ls

폴더에 어떤 목록이 있는지 보는 것
(team_test/)

cd team_test

team_test 파일로 이동하는 것
(main)

git branch -a

(* main
  remotes/origin/HEAD -> origin/main
  remotes/origin/development
  remotes/origin/main)
cf) 초록색 = 로컬 레파지토리에 있는 것.
    빨간색 = 원격 레파지토리에 있는 것.

git checkout -t remotes/origin/development

원격레파지토리에 있는 것을 내 로컬로 끌고 오면서 이동까지 하는 것.
(Switched to a new branch 'development'
branch 'development' set up to track 'origin/development'.) (development)

git checkout -b yujin

(Switched to a new branch 'yujin')

git push --all
(Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: Create a pull request for 'yujin' on GitHub by visiting:
remote:      https://github.com/rbdus0515/team_test/pull/new/yujin
remote:
To https://github.com/rbdus0515/team_test.git
 * [new branch]      yujin -> yujin)

code .

vscode 켜는 문구

(내 코드 변경사항 후)

git status

git add .

git status

git commit -m"yujin commit"

cf) commit 문구는 변경사항 한 눈에 알 수 있게 작성하기!

git push

cf) 처음 push 할 때만 하단 문구로 작성!
git push --set-upstream origin yujin


(Merge)

  1. 깃허브 -> Pull requests 하기
  2. New pull request 하기
  3. base : development <- compare : yujin 원격저장소(브랜치) 이동하기
  4. Create pull request 누르기
  5. 수정 주석 달고, Create pull request 누르기
  6. 조장과 상의 후 같이 Merge 하기
  7. Merge가 정상적으로 완료되면 하단 화면

(Merge 끝난 후 내 로컬 컴퓨터로 가져오기)

이것만 보기 !!!!!!!!
git pull origin development

development로 계정 옮기지 않아도 내 계정에서 바로 development git pull 가능함.

git checkout development

git pull . development

중요 !

There is no tracking information for the current branch.
Please specify which branch you want to rebase against.
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> feature/foo-branch
[출처] Git pull 실행시 "no tracking information for the current branch" 오류 해결하기|작성자 꼼꼼한 재은씨

문제는 단순하다.

  1. 리모트 저장소인 Origin에서 브랜치를 내려받아 병합하려고 시도했다.
  2. 로컬에 동일한 디렉토리가 이미 존재한다(물론 눈으로 확인할 수는 없다).
  3. 합치려고 보니 로컬 디렉토리에는 브랜치 추적 정보가 없다. 그러니 병합할 브랜치를 지정하라 라는 것

위 오류는 원격 저장소에서 내려받을 브랜치와 동일한 이름의 브랜치가 로컬에 이미 존재할 때 발생한다.

해결방법은

$ git branch --set-upstream-to=origin/<원격 브랜치명> <로컬 브랜치명>
실제로는 이렇게 git bash에 작성하기

$ git branch --set-upstream-to=origin/development development

위를 실행했을 시 하단의 실행결과 나옴 : 원격브랜치와 로컬브랜치를 연결만 시켰다.
Branch 'feature/foo-branch' set up to track remote branch 'feature/foo-branch' from 'origin'.
병합 진행

$ git pull

위를 실행했을 시 하단의 실행결과 나옴
Updating 288b7b7..6ca6207
Fast-forward
 yj_test.html | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 yj_test.html

꼭! development -> yujin 으로 브랜치 변경하여 파일 수정하기 !

git checkout yujin
  • 위 과정의 반복.

GIT 정리

CF ) 자리 이동 시, Windows 자격 증명 변경


편집 클릭 후 사용자 이름 변경

암호 = git 토큰 복사하기

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

0개의 댓글