강아지를 좋아하는 컴공생

[Git] 명령어 순서 본문

카테고리 없음

[Git] 명령어 순서

정인하이 2022. 11. 5. 17:42

협업시 작업 순서

[pull] → [작업] → [commit] → [pull](이전 시간 동안 누가 작업했을 수도) → [push]

 

 

git 명령어 순서

1. git status
2. git add .                                => 뒤에 점과 그 사이 공백 유의
3. git commit -m "메세지"       => 내 branch에만 
4. git pull origin main             => pull 후에 push
5. git push origin jeongin      => 내 branch에만 push
   
    git push origin main           => main branch에 push
                                                 => 이거 안 되면 밑의 방법 적용하면 main branch에 push됨

 

브랜치를 바꾸고, 바꾼 브랜치로 push 해주시면 됩니다.(성공함)
git branch -M main
git push origin main

출처 : https://velog.io/@s_yeah/Git-git-push-origin-main-에러

 

 

 

 

merge vs rebase

협업시 rebase는 지양. 되도록이면 merge로 사용할 것.

merge 할 때는 막 하면 안 되고 신중하게 할 것.

 

 

 

 

이외 명령어

status : 파일 상태들 확인
ignore : 파일 지정함으로서 특정 파일을 
diff : 변경된 사항

 

 

 

pull 할 때 충돌방지하기 위해 2가지 방법이 있다.
-merge방식(default)
-rebase방식

 

 

 

 

commit

$ commit -am "커밋메세지"            => add생략하고 commit 하는거

 

commit은 자주해두자.

특히 수정 내용이 있을 땐 '딱 그 수정내용'되었을 시점에 commit 해놓자.

다른 수정사항들도 포함하지 말고

 

 

 

이외 명령어들

[Git 레퍼런스]에서 명령어 & 옵션들 확인 가능

https://git-scm.com/docs

 

Git - Reference

Reference

git-scm.com