-
Notifications
You must be signed in to change notification settings - Fork 1
Git 기능 사용법
터미널 & 인텔리제이 & 소스트리 3가지 방법을 모두 설명드리겠습니다. 각자 편하신 방법을 선택하시면 됩니다. (소스트리 같은 GUI를 사용하시는 것을 권장드립니다.)
git branch 브랜치이름

인텔리제이 왼쪽 하단을 보시면 Terminal 칸이 있습니다. 터미널을 열 수 있고 명령어를 칠 수 있습니다!
git branch

위 명령어를 입력하면, 현재 존재하는 branch 목록을 볼 수 있습니다. main과 방금 만든 mybranch 브랜치 두 개가 있습니다.
git checkout 브랜치이름
위 명령어를 치면, 브랜치이름
으로 이동할 수 있습니다.

인텔리제이 오른쪽 하단을 보시면 브랜치 아이콘이 있고, 현재 브랜치(main) 이름이 보입니다.


다시 브랜치 아이콘을 눌러보면, 브랜치 목록을 확인할 수 있고, 눌러서 checkout도 가능합니다.

우선 소스트리를 설치하시고, 로그인 등 가입 절차를 진행해주세요!

왼쪽의 브랜치에서 우클릭하여 New Branch를 해줍니다.

Create Branch 해주면 끝!

생성된 브랜치 목록을 볼 수 있고, 더블클릭하면 checkout이 가능합니다.
우선! 작업할 branch
로 checkout
합니다.
아래의 명령어를 순차적으로 입력해주세요.
git add .
현재 작업한 것들을 statge에 올립니다.
git commit -m "커밋메세지"
git commit 만 해도 (뒤에 -m “커밋메세지”를 붙이지 않아도) default 커밋 메세지가 적용되는 것으로 알고 있습니다. 하지만 유의미한 커밋 메시지를 남기는 연습은 중요하다고 생각합니다!
git push
커밋 내역을 원격으로 push 합니다.

상단의 Git → Commit을 눌러줍니다.

체크해서 stage에 올릴 수 있습니다. (git add .)에 해당하는 부분입니다.

바로 아래에서 커밋메세지를 정리하여 Commit
할 수 있고, Commit and Push
하면 바로 push도 됩니다.

왼쪽 상단을 보시면 Commit 버튼이 있고, 변경된 파일의 개수가 표시되어 있습니다.

눌러주시면 Commit 창으로 이동할 수 있고, Unstaged files들을 체크하여 stage에 올릴 수 있습니다.

아래에서 커밋 메시지를 작성할 수 있고, Commit
을 할 수 있습니다.
아래의 push changes immediately to origin/main을 체크하시면 Commit
과 동시에 push
를 할 수 있습니다.

push
를 하지 않았다면 push
되지 않은 커밋 내역들이 표시되며, push
버튼을 눌러서 push
할 수 있습니다.
위의 방법으로 원격으로 push
하셨다면, push
한 깃허브의 원격 레포로 이동합니다.

그럼 Pull Request
을 날릴 거냐고 묻는 창이 나오며, Compare & pull request
를 눌러서 PR
을 작성하시면 됩니다.

git reset HEAD~1
1 : 1개의 커밋 취소
2 : 2개의 커밋 취소
n : n개의 커밋 취소