Git 명령어

Jinsu Kim·2021년 11월 27일
0

git

목록 보기
1/1

pwd

현재 자신이 어느 위치에 있는지 알려준다.

cd/c/Users/2019AFT/git

※ 공간(파일)을 이동하고 싶은 경우
cd 와 자신이 가고 싶은 주소를 입력하면 이동된다.

※ git의 명령어

start a working area (see also: git help tutorial) 
   clone             Clone a repository into a new directory 
   init              Create an empty Git repository or reinitialize an existing one 

work on the current change (see also: git help everyday) 
   add               Add file contents to the index 
   mv                Move or rename a file, a directory, or a symlink 
   restore           Restore working tree files 
   rm                Remove files from the working tree and from the index 
   sparse-checkout   Initialize and modify the sparse-checkout 

examine the history and state (see also: git help revisions) 
   bisect            Use binary search to find the commit that introduced a bug 
   diff              Show changes between commits, commit and working tree, etc 
   grep              Print lines matching a pattern 
   log               Show commit logs 
   show              Show various types of objects 
   status            Show the working tree status 

grow, mark and tweak your common history 
   branch            List, create, or delete branches 
   commit            Record changes to the repository 
   merge             Join two or more development histories together 
   rebase            Reapply commits on top of another base tip 
   reset             Reset current HEAD to the specified state 
   switch            Switch branches 
   tag               Create, list, delete or verify a tag object signed with GPG 

collaborate (see also: git help workflows) 
   fetch             Download objects and refs from another repository 
   pull              Fetch from and integrate with another repository or a local branch 
   push              Update remote refs along with associated objects 

'git help -a' and 'git help -g' list available subcommands and some 
concept guides. See 'git help ' or 'git help ' 
to read about a specific subcommand or concept. 
See 'git help git' for an overview of the system. 

※ 기존 디렉터리를 Git 저장소로 만들기

git init

이 명령어는 .git 이라는 하위 디렉터리를 만드는 명령어이다.

내가 현 디렉토리에서 작업을 진행하겠다는 것을 git에다가 알려주는 역할

git 디렉터리에는 저장소에 필요한 Skeleton이 들어 있다.

이 명령만으로는 아직 프로젝트의 어떤 파일도 관리하지 않는다.

git status
git status -s (간단하게 보여줌

※ git의 상태 조회
다른 파일의 상태를 확인 하고 싶을 때 git status를 사용한다.

빨강색이 나오는 이유는 아직 untracked files 되어 있기 때문이다.
아직 버젼관리를 하지 않아도 된다는 의미이다.
파일을 버젼관리를 하기 위해서는 add 명령어가 필요하다

git add

※ Stage 영역에 파일을 올린다.

git add hello.txt를 한뒤 git status 명령어로 확인해보면 hello.txt 파일이 초록색으로 된 것을 확인 할 수 있다.

git commit

※ git 버젼 만들기
1. git commit을 누르면 이런 화면으로 넘어간다.

  1. i를 누른뒤 파일의 정보 또는 설명을 써준다

  2. ESC키를 누른다

  3. :wq를 누룬 후 종료한다

  4. 완료!

git log

※ 기본적인 커밋 히스토리 조회
git에서 커밋 히스토리를 조회하고자 할 때 사용한다.

  • Author : 실제로 커밋을 한 사람

Commiter : 커밋을 Git repository에 저장한 사람

git clone

※ 기존 저장소를 Clone(복제) 하기
다른 프로젝트에 참여하거나 Git 저장소를 복사 할 경우 git clone 명령어를 사용한다.

git remote

※ git의 원격 저장소를 관리한다

github의 나온 파일 올리는 과정(종합)

echo "# J_git" >> README.md

git init

git add README.md

git commit -m "first commit"

git remote add origin "emial 주소"

git push -u origin master
  
profile
Ruby와 js로 첫 커리어를 시작하였고 3년차 엔진니어입니다! vim에 관심이 많습니다!

0개의 댓글