[git] 명령어 모음

제이브로·2024년 2월 1일
0

git

목록 보기
7/11
post-thumbnail

1. git clone

githubpractice 레포지토리 소스 코드 복제 및 다운로드하는 명령어

$ git clone https://github.com/jbro321/practice.git

2. git add

변경된 파일을 stage 상태로 만드는 명령어

  • practice.pystage한다.
$ git add practice.py

Q.Stage란?
A. 수정 및 생성한 파일을 깃허브에 올리기 전 단계라고 보시면 됩니다. 이 파일들을 올릴거다하는 확인단계입니다.

  • practice repository의 변경사항이 있는 파일을 모두 stage 상태로 만드는 명령어입니다. (add 뒤에 띄어쓰기해야됩니다. 주의해주세요.)
$ git add .
  • stage한 파일들 전부를 unstage하는 명령어입니다.
$ git reset HEAD --
  • stagepractice.py 파일을 unstage하는 명령어입니다.
$ git reset HEAD practice.py

3. git commit

Stage한 파일을 github에 올리기 직전 단계로 push 되기 전 단계

  • 1st commit이라는 메세지로 commit합니다. `
git commit -m "1st commit"

4. git push

커밋된 이력들을 github에 올리는 명령어

  • github에 연결된 main이라는 branchcommit된 변경사항들을 업로드
$ git push origin main
  • test branchpush
$ git push --set-upstream origin test

6. git pull

github에서 변경된 내용들을 가져오는 명령어

  • github의 변경 내용을 현재 내 directory가져오고(fetch) 병합(merge)합니다.
$ git pull

7. git remote

git remote를 통해서 기존 폴더를 github에 연결하는 방법

  1. git 초기화
$ git init
  1. git 파일을 stage합니다
$ git add .
  1. stage한 파일을 1st commit 이라는 메세지로 commit
$ git commit -m "1st commit"
  1. github_url에 등록
$ git remote add origin [github_url.git]
  1. github의 main 브랜치에 업로드
$ git push -u origin main

8. git branch

  • githubbranch 현황을 보여줍니다.
$ git branch
  • githubnew_branch이라는 이름으로 branch를 만듭니다.
$ git branch "new_branch"
  • new_branch로 이동합니다.
$ git checkout new_branch
  • main에서 test branch로 복사
$ git push origin main:test

감사합니다.

profile
기록하지 않으면 기록되지 않는다.

0개의 댓글