>git clone [원격 주소]
> git clone https://github.com/jyheo/test2.git Cloning into 'test2'... remote: Counting objects: 5, done. remote: Compressing objects: 100% (4/4), done. remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (5/5), done. Checking connectivity... done. > ls test2 [test2라는 폴더가 새로 생성됨] Directory: C:\Users\jyheo\test2
> git remote add origin https://github.com/jyheo/test2.git > git branch -M master [현재 브랜치 이름을 master로 변경, 이미 master라면 할 필요 없음] > git push -u origin master [ -u 옵션은 tracking 브랜치 연결을 위해 필요]
> git remote -v
> git remote -v origin https://github.com/jyheo/test2.git (fetch) origin https://github.com/jyheo/test2.git (push)
> git remote add
> git branch -a
> git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/master
출처: https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches
> git push [원격 이름] [로컬 브랜치 이름]
> git commit -m "test" [새 변경 이력 생성] [master 4a52752] test 1 file changed, 1 insertion(+) create mode 100644 test.c > git status [현재 상태 확인] On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) nothing to commit, working tree clean > git push [git push 원격 이름과 로컬 브랜치 이름 생략] Username for 'https://github.com': jyheo Password for 'https://jyheo@github.com': Enumerating objects: 4, done. Counting objects: 100% (4/4), done. Delta compression using up to 16 threads Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 275 bytes | 275.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0) To https://github.com/jyheo/test-repo.git 2bafe99..4a52752 master -> master
> git push origin master
> git push
> git fetch [원격_이름]
> git fetch [원격 이름을 생략하면 default는 origin] remote: Enumerating objects: 5, done. remote: Counting objects: 100% (5/5), done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), 654 bytes | 43.00 KiB/s, done. From https://github.com/jyheo/test-repo 4a52752..8ef157d master -> origin/master > cat README.md [커밋을 가져오기만 하고 로컬 브랜치에 합치지는 않음] test
> git merge [브랜치이름]
> git merge origin/master > git merge [브랜치이름 생략하면 현재 브랜치의 트래킹 브랜치] Updating 4a52752..8ef157d Fast-forward README.md | 1 + 1 file changed, 1 insertion(+) > cat README.md test [합쳐진 결과로 한줄 추가된 것이 확인 됨] new test
> git merge origin/master
> git branch -vv
> git branch -vv * master 4a52752 [origin/master] test
> git branch testing [로컬 브랜치] > git checkout testing Switched to branch 'testing' > echo "" > testfile > git add testfile > git commit -m "testfile added" [testing daf25d2] testfile added 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 testing > git push -u origin testing [원격지 origin에 testing 브랜치 push] Username for 'https://github.com': jyheo Password for 'https://jyheo@github.com': Counting objects: 3, done. Delta compression using up to 4 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 271 bytes | 0 bytes/s, done. Total 3 (delta 1), reused 0 (delta 0) remote: Resolving deltas: 100% (1/1), completed with 1 local objects. To https://github.com/jyheo/test.git * [new branch] testing -> testing
> git checkout -b [로컬 브랜치] [원격 브랜치]
> git fetch origin [원격 저장소 내용 최신으로 가져오기] > git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/master remotes/origin/new remotes/origin/testing > git checkout -b testing origin/testing Branch testing set up to track remote branch testing from origin. Switched to a new branch 'testing' > git branch -vv [트래킹 브랜치 확인] master 8f6ad29 [origin/master] Update jyheo * testing 16fbdb2 [origin/testing] hello
> git pull