카테고리 없음

git 명령어들 확인해보자

devWarrior 2022. 2. 21. 10:30

git 연결해서 pull하기

git init , config , git remote add origin github주소, git pull -u origin main, 

 

....or create a new repository on the command line

echo "# myPortfolio" >> README.md

git init

git add README.md

git commit -m "first commit"

gir remote add origin github주소

git push -u origin main 

...or push an existing repository from the command line

git remote add origin github주소

git branch -M main

git push -u origin main

 

 

git pull github주소 --> github 기존저장소 소스 가져오는 동시에 연결 / 작업 끝난후 다시 push로 병합가능

git pull github주소 --> github 기존저장소 소스 가져온다 / 작업 끝난후 다시 push로 병합 가능 

git pull origin main ( origin 에서 main으로 땡겨 오겠다 ) 

 

참고자료 https://sin0824.tistory.com/11

Ctrl + shift + p  => 명령창 

 

merge 하는법

- sub이라는 branch를 생성 후 터미널을 sub으로 바꾼 후 원하는 code를 작성한다 -> code작성 후 commit 까지 완료 한다 -> sub이라는 branch에서 commit한 코드를 master라는 branch로 merge 하고자 한다 

 

위 작업을 실행하기 위한 명령어는 ....

1. 새로운 branch 만들기 

 -> git branch  sub

2. 현재 작업터미널을 새로운 branch로 바꾸기

 -> git checkout sub 

3. 새로운 code 작성 및 add 후 commit 

 -> git add. ->git commit -m "newCommit"

4. sub 브런치에서 commit한 code를 master로  까지 완료 후 다시 병합할 branch로 변경 후 merg할 branch를 지정

 -> git checkout master --> git merge sub