Original Source: https://dev.classmethod.jp/articles/git-bash-commands
Git Bash Commands | DevelopersIO
WHY GIT? In today’s scenario of real world problem solving mechanism Git has been so handy in continuous proje …
dev.classmethod.jp
BASIC STUFFS
cd "[path]"
: 해당 디렉토리로 이동
mkdir "[directory name]"
: 디렉토리 생성
rm -r "[directory name]"
: 해당 디렉토리와 디렉토리 내부의 파일들을 삭제(휴지통을 거치지 않고 바로 완전삭제되니 주의!).
Ctrl + insert
: 텍스트 복사(Ctrl + C)
insert / Shift + Insert
: 텍스트 붙여넣기(Ctrl + V)
SETUP
git config --global user.name “[name]”
: 유저 이름 설정
git config --global user.email “[email address]”
: 유저 이메일 설정
git config --global color.ui auto
: 자동적으로 command line에 색을 칠해 줌
CREATE AND INITIALIZE
git init
: 현재 디렉토리를 git 디렉토리로 설정함.
git init [repository name]
: 새로운 git repo를 만들 때 사용.
git clone [url]
: local에 이미 존재하는 git repo의 최신 버전을 복제하여 저장.
rm -fr .git
: 해당 디렉토리의 git 삭제
STAGING AND COMMIT
git add [file]
: 한 개의 파일을 Staging area / 현재 branch에 저장.
git add *
: 한 개 또는 여러 개의 파일을 Staging area / 현재 branch에 저장.
git add .
: 현재 repo의 모든 파일을 Staging area / 현재 branch에 저장.
git rm [file]
: 디렉토리의 파일 삭제.
git status
: 지금까지 commit한 모든 파일을 나열함.
git diff
: 내용이 변경되었지만 아직 stage되지 않은 파일들을 보여 줌.
git diff --staged
: 내용이 변경되고 stage도 되었지만 아직 commit되지 않은 파일들을 보여 줌.
git commit -m “[commit message]”
: 모든 변경된 파일들을 commit.
git commit -a
: 모든 변경/생성된 파일들을 commit.
git reset [file]
: 파일을 unstage.
git reset [commit]
: 해당 commit 이후의 모든 commit들을 원래대로 되돌리고 history를 local에 저장함.
git reset --hard [commit]
: 해당 commit 이후의 모든 commit들을 원래대로 되돌리고 history를 저장하지 않음.
BRANCH AND MERGE
git branch
: 사용 가능한 모든 branch를 나열.
git branch [branch name]
: 새로운 branch를 생성.
git branch -d [branch name]
: 해당 branch를 삭제.
git checkout [branch name]
: 해당 branch로 전환.
git checkout -b [branch name]
: 새로운 branch를 생성하고 해당 branch로 전환.
git merge [branch name]
: 해당 branch를 현재 branch로 merge.
LOGS AND REVIEW
git log
: 현재 branch의 history를 나열.
REMOTE UPDATE AND SHARE
git remote add [variable name] [URL]
: local repo를 원격 저장소에 연결.
git push [variable name] [branch name]
: branch의 commit을 원격 저장소에 보냄(=push).
git push --set-upstream [variable name] [branch name]
or</b >
git push -u origin [branch name]
: 새로 생성된 branch에서 파일을 push할 수 있도록 만듦(자세한 건 모르겠다).
git push [variable name] master
: master branch에서 commit된 파일들을 원격 저장소로 보냄
git push -all [variable name]
: 모든 branch를 원격 저장소로 push.
git fetch [repository link]
: 원격 저장소의 변경 사항을 local로 가져옴.
git pull [repository link]
: 원격 저장소의 변경 사항을 local에 가져와서 merge함.
'기타' 카테고리의 다른 글
[Notion] 윈도우 앱 무한로딩 해결하는 법 (0) | 2022.08.04 |
---|---|
[Git Bash] Personal access token으로 GitHub 인증하기 (0) | 2022.08.02 |