[GIT] MacOS에서 Git 사용하기
1. 터미널에서 깃 저장소로 사용할 디렉토리로 이동해서
git init 을 입력해 이 디렉토리를 로컬 Git저장소라고 알려주는 작업을 함
drwx------@ 4 we staff 128B 7 6 15:49 Applications
drwx------+ 49 we staff 1.5K 8 31 00:43 Desktop
drwx------+ 6 we staff 192B 8 29 23:36 Documents
drwx------@ 107 we staff 3.3K 8 31 00:44 Downloads
drwx------@ 65 we staff 2.0K 7 9 15:57 Library
drwx------+ 4 we staff 128B 7 6 09:38 Movies
drwx------+ 4 we staff 128B 7 12 23:48 Music
drwx------+ 4 we staff 128B 6 29 13:43 Pictures
drwxr-xr-x+ 4 we staff 128B 6 29 11:58 Public
drwxr-xr-x@ 3 we staff 96B 6 13 11:05 Sourcetree.app
drwxr-xr-x@ 16 we staff 512B 7 6 16:46 apache-tomcat-8.5.68
drwxr-xr-x 2 we staff 64B 8 31 00:55 toyWorkspace
drwxr-xr-x 12 we staff 384B 8 30 14:51 workspace
➜ ~ cd toyWorkspace
➜ toyWorkspace git init
힌트: Using 'master' as the name for the initial branch. This default branch name
힌트: is subject to change. To configure the initial branch name to use in all
힌트: of your new repositories, which will suppress this warning, call:
힌트: git config --global init.defaultBranch <name>
힌트: Names commonly chosen instead of 'master' are 'main', 'trunk' and
힌트: 'development'. The just-created branch can be renamed via this command:
힌트: git branch -m <name>
/Users/we/toyWorkspace/.git/ 안의 빈 깃 저장소를 다시 초기화했습니다
2. git add {파일명} 를 입력
add . 은 이 디렉토리의 수정된 모든 파일을 스테이지에 올린다
git add 소스.java 는 소스.java 파일의 수정된 부분을 스테이지에 올린다
3. git commit -m "코멘트"
add 했던 변경점들을 해당 코멘트를 달고 커밋하겠다는 의미로
스테이지에 올렸던 변경점들을 Git Repository로 올린다. 커밋은 간결하게 한 작업단위로 묶어 그때그때 해주는 것이 좋다.
예) git commit -m "2번작업"
4. git remote add <origin:단축이름> <https://github.com/JeeyunHwang/JeeyunHwang.git:url>
자신이 사용하는 Git 주소에 리모트 저장소를 추가한다.
기존 워킹 디렉토리에 새 리모트 저장소를 추가한다
5. git push -u <리모트저장소이름:origin> <브랜치이름:master>
Upstream 저장소에 push 한다. master 브랜치를 origin 서버에 push한다.