Symptoms |
---|
- 버전관리를 위한 Bitbucket의 로컬과 원격지에서의 사용법
Environment |
---|
- 로컬레포지토리 : NT
- 원격레포지토리 : Bitbucket
Solution |
---|
- local에서의 사용방법
local repository에 파일생성 또는 수정
예제파일명(alertlog_pattern_check.txt) 생성
git status명령으로 repository의 상태확인
Administrator@CSLEE-GIT1 MINGW64 /d/repos/modulelocation (master)
$ git status
On branch master
Your branch is up to date with ‘origin/master’.Untracked files:
(use “git add …” to include in what will be committed)
alertlog_pattern_check.txtnothing added to commit but untracked files present (use “git add” to track)
Administrator@CSLEE-GIT1 MINGW64 /d/repos/modulelocation (master)
$
Untracket된 파일확인(alertlog_pattern_check.txt)
git add명령을 이용해 staging영역에 해당파일을 추가한다.
Administrator@CSLEE-GIT1 MINGW64 /d/repos/modulelocation (master)
$ git add ./alertlog_pattern_check.txtAdministrator@CSLEE-GIT1 MINGW64 /d/repos/modulelocation (master)
$ git status
On branch master
Your branch is up to date with ‘origin/master’.Changes to be committed:
(use “git restore –staged …” to unstage)
new file: alertlog_pattern_check.txtAdministrator@CSLEE-GIT1 MINGW64 /d/repos/modulelocation (master)
$
staging
스테이징 영역은 커밋할 준비가 된 변경 내용이 Git 저장소에 기록되기 전에 대기하는 장소
git add
.$ git add <파일/디렉토리 경로>
작업 디렉토리의 변경 내용의 일부만 스테이징 영역에 넘기고 싶을 때는 수정한 파일이나 디렉토리의 경로를 인자로 한다.
$ git add .
현재 디렉토리의 모든 변경 내용을 스테이징 영역으로 넘기고 싶을 때는, .을 인자로 한다.
$ git add -A
작업 디렉토리 내의 모든 변경 내용을 몽땅 스테이징 영역으로 넘기고 싶을 때는, -A 옵션을 사용한다.
git add -A는 작업 디렉토리 상에 어디에 위치하든 항상 동일하게 모든 변경 내용을 스테이징으로 넘긴다.
반면에 git add .는 명령어를 실행한 디렉토리 이하에서 발생한 변경 내용만 포함하며,
해당 디렉토리 기준으로 상위 디렉토리의 변경 내용을 포함하지 않는다.
만약에 git add .를 프로젝트 최상위 디렉토리에서 실행한다면 git add -A와 동일한 효과를 가져온다.
$ git add -p
각 변경 사항을 터미널에서 직접 눈으로 하나씩 확인하면서 스테이징 영역으로 넘기거나 또는 제외할 수가 있다.
많은 변경 내용을 여러 개의 변경 기록으로 나누어서 남기고 싶을 때 유용하게 사용된다.
git commit명령으로 변경부분에 대한 저장을 한다.
Administrator@CSLEE-GIT1 MINGW64 /d/repos/modulelocation (master)
$ git commit -m ‘alertlog_pattern_insert’
[master 44354a6] alertlog_pattern_insert
1 file changed, 61 insertions(+)
create mode 100644 alertlog_pattern_check.txtAdministrator@CSLEE-GIT1 MINGW64 /d/repos/modulelocation (master)
$
commit명령은 반드시 해당 변경부분에 대한 완료가 되어있는 상태여야한다.
git commit
$ git commit -m “메세지”
commit을 하면 stage영역은 초기화된다.
working tree clean 메세지- 더이상 추가된 새로운 파일과 수정된 파일이 없다는 의미
$ git commit -am “메세지”
add와 commit 동시에 실행
$git commit –allow-empty-message -m “”
메세지 없이 커밋할 수 있는 명령어이다.
git push명령으로 원격저장소에 해당내용 적용
Administrator@CSLEE-GIT1 MINGW64 /d/repos/modulelocation (master)
$ git push origin master
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 1.08 KiB | 1.08 MiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To https://bitbucket.org/chulsoonlee/modulelocation.git
5435b0d..44354a6 master -> masterAdministrator@CSLEE-GIT1 MINGW64 /d/repos/modulelocation (master)
$
git push
$ git push <remote> <branch>
사용자가 이 두 매개변수를 지정하지 않는다면 Git는 기본적으로 origin을 원격 저장소로,
현재 작업하고 있는 브랜치를 푸시할 브랜치로 지정된다.
원격저장소(bitbucket) 확인

Workaround |
---|
- N/A