MAC

[MAC] GIT feat. MAC

아람2 2024. 9. 9. 10:50
반응형

남(?)의 레포에 내 브랜치를 만들고 싶을 때 

여기 부분 은 연결한 이후에 진행 

 

저장소를 클론한다

git clone <원격 저장소 URL>

 

클론한 디렉토리로 이동한다

cd <저장소 디렉토리>

 

원격 저장소 추가한다 

git remote add origin <원격 저장소 URL>

 

새 브랜치를 생성하고 체크아웃한다

git checkout -b <브랜치이름>

 

git add .

git commit -m 'COMMIT'

* Add 하면 Branch 이름이 노랑색으로 변경됨 (원격)

* Commit 하면 Branch 이름이 초록색으로 변경됨 (로컬)

 

git push origin <브랜치 이름> 

하면 내가 선택한 브랜치로 push가 된다!!



 

ㅡ pull 은 아직 안 해 봄 

원격 브랜치의 최신 변경 사항을 가져온다

git pull origin helloahram


원격 브랜치 삭제하기

git push origin -d <원격브랜치>

 

+ 개인적으로 사용하는 Git Repo 에 Push 하려 했는데 Push 가 안 된다

 ahram@Ahramui-MacBookPro  ~/Desktop/Jungle/Algorithm   main  git pu
sh
To https://github.com/helloahram/algorithm.git
 ! [rejected]        main -> main (non-fast-forward)
error: failed to push some refs to 'https://github.com/helloahram/algorithm.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

 그래서 Pull 해보니, 원격 저장소에 백준허브가 자동으로 올린 파일들이 있었다

그래서 git fetch/ merge 를 해서 commit MSG 설정 후에 merge 가 됐다!

git fetch origin

git merge origin/main 

그리고 나서 push!

git push origin main

 

 

+ 09/19 THU 알게된 것

branch 가 있을 때, branch 에 checkout 한 상태이면

graph 에서 branch 의 동그라미가 비어 보인다

main branch 로 이동하면 main 의 동그라미가 비어 보인다

 동그라미가 비어 있어서 merge 가 안 된 줄 알았는데 아니었다 

 

 

 

 

/KJ-W01-03-7-2/Week01   helloahram  cd ..
(myevn)  ahram@Ahramui-MacBookPro  ~/Desktop/Jungle2/Week01/ahramGit/KJ-W01-03-7-2   helloahram  git
 checkout main
Switched to branch 'main'
Your branch is behind 'origin/main' by 76 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
(myevn)  ahram@Ahramui-MacBookPro  ~/Desktop/Jungle2/Week01/ahramGit/KJ-W01-03-7-2  ↰ main  git pull 
origin main
From https://github.com/krafton-jungle/KJ-W01-03-7-2
 * branch            main       -> FETCH_HEAD
Updating 6e3b853..7b4de3c
Fast-forward
... 생략 ...
 49 files changed, 974 insertions(+)
... 생략 ...
(myevn)  ahram@Ahramui-MacBookPro  ~/Desktop/Jungle2/Week01/ahramGit/KJ-W01-03-7-2   main  git check
out helloahram
Switched to branch 'helloahram'
(myevn)  ahram@Ahramui-MacBookPro  ~/Desktop/Jungle2/Week01/ahramGit/KJ-W01-03-7-2   helloahram  git merge main
Updating 4ea572d..7b4de3c
Fast-forward
... 생략 ...
(myevn)  ahram@Ahramui-MacBookPro  ~/Desktop/Jungle2/Week01/ahramGit/KJ-W01-03-7-2   helloahram  

반응형