본문 바로가기

형상관리

[220406] 깃 bash, clone, fork

새로운 작업 시작하기 전에는 항상 공동작업한 레포 pull를 선행

각자 레포를 클론한 다음 작업한다고 가정했을 때
 
1. 공동작업하는 레포를 내 레포로 clone한다.
2. clone한 내 레포에서 작업(commit & push)
3. 작업이 완료되면 내 레포에서 작업한 내용들을 공동작업한 레포로 push한다.
 
 
 
공동작업하는 레포를 내 레포로 fork해서 작업하는 경우

1. 공동작업할 레포를 내 레포로 fork한다.
2. 내 레포에서 작업할 내용들을 commit & push 한다.
3. 작업이 완료되면 공동작업할 레포로 pull request 한다.
4. 공동작업할 레포의 권한있는 관리자가 코드에 문제가 없다고 판단했을 경우 pull request를 승인한다.

cd '~~' - ~~ 경로로 체인지 디렉터리 (그냥 슬래시로 구분, 역슬래시 - no such directory 오류)

(dev) (master) : 브랜치명

git 명령어 치기 전 초기 위치는 .git 파일이 있는 프로젝트 폴더 내부로 옮겨간 상태여야 한다.

깃 배시상에서 ctrl c v 안 먹힘 -> 복사 ( control + insert ) 붙여넣기 ( shift + insert) 

 

git status - 작업 스테이깅 확인

git add - 깃(로컬저장소-스테이징영역)에 로컬에 생성된 파일 추가

git add * - 깃(로컬저장소-스테이징영역)에 로컬에 생성된 파일 모두 추가

git remote -v - 깃(원격) 저장소와 엮인 깃허브 주소(패치 푸쉬 작업이 반영되는 위치 확인)

git remote show 깃원격저장소이름(ex.origin) - 리모트 저장소의 구체적인 정보를 확인

(명령어 치기 전 초기 위치는 .git 파일이 있는 프로젝트 폴더 내부로 옮겨간 상태여야 한다.)

git checkout -d dev : 원래는 체크아웃 기능만 있는건데 -d 옵션을 통해 dev브랜치가 없다면 생성하고 체크아웃한다.

git checkout -help 쓰면 추가 옵션정보 확인가능

 

커밋 먼저해서 수정사항을 반영시킨 후에 깃 원격저장소에 해당 브랜치로 푸쉬하여야 한다.

git commit -m'third test' : -m 옵션으로 커밋메시지를 넣고 지금까지의 로컬 수정사항을 커밋한다.(지역저장소에 저장)

 

brique115@DESKTOP-K8FGOI8 MINGW64 ~/OneDrive/바탕 화면/gittest/gittest (dev)

git push origin dev : 현재 로컬브랜치 dev에서 origin(원격저장소)의 dev원격브랜치로 모든 수정사항들을 푸쉬한다.

 

git log : 로그보기(시간,날짜, 상세정보)

git log --oneline : 간단히 로그보기

brique115@DESKTOP-K8FGOI8 MINGW64 ~
$ cd '/c/Users/leemi/OneDrive/바탕 화면/gittest/gittest'

brique115@DESKTOP-K8FGOI8 MINGW64 ~/OneDrive/바탕 화면/gittest/gittest (dev)
$ git status
On branch dev
Your branch is up to date with 'origin/dev'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        second dev.txt

nothing added to commit but untracked files present (use "git add" to track)

brique115@DESKTOP-K8FGOI8 MINGW64 ~/OneDrive/바탕 화면/gittest/gittest (dev)
$ git add *

brique115@DESKTOP-K8FGOI8 MINGW64 ~/OneDrive/바탕 화면/gittest/gittest (dev)
$ git remote -v
origin  https://github.com/epikbb/gittest.git (fetch)
origin  https://github.com/epikbb/gittest.git (push)

brique115@DESKTOP-K8FGOI8 MINGW64 ~/OneDrive/바탕 화면/gittest/gittest (dev)
$ git push origin master
Everything up-to-date

brique115@DESKTOP-K8FGOI8 MINGW64 ~/OneDrive/바탕 화면/gittest/gittest (dev)
$ git push origin dev
Everything up-to-date

brique115@DESKTOP-K8FGOI8 MINGW64 ~/OneDrive/바탕 화면/gittest/gittest (dev)
$ git commit -m'third test'
[dev c09a5a7] third test
 1 file changed, 1 insertion(+)
 create mode 100644 second dev.txt

brique115@DESKTOP-K8FGOI8 MINGW64 ~/OneDrive/바탕 화면/gittest/gittest (dev)
$ git push origin dev
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 245 bytes | 245.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/epikbb/gittest.git
   d57aef7..c09a5a7  dev -> dev

brique115@DESKTOP-K8FGOI8 MINGW64 ~/OneDrive/바탕 화면/gittest/gittest (dev)
$ git log --oneline
c09a5a7 (HEAD -> dev, origin/dev) third test
d57aef7 commit dev branch
07e17f5 test commit
dec650d (origin/master, origin/HEAD, master) second commit
affa8d4 commit&push test
1998ff5 01_DrumKit/myAnswer
ce2c7e6 Update style.css
8fa8dd7 Add files via upload
ac5ce1a Merge pull request #406 from lillapulay/master
80ec671 Mixed the order of items in the 'people' array
bf1d914 Mixed the order of items in the 'people' array
b21b66f Merge pull request #368 from novibonjovi/master
1afca64 Merge pull request #373 from FriscoTony/tinyfix
d6a3a6e Merge pull request #379 from Eduardo06sp/master
a584dc2 Merge pull request #381 from gupta-ji6/master
b23d144 Move the link to last index
c24e6bd Add a link in community resource
1a66a6f Fix sound not playing by lengthening audio file
b1f85a6 docs: update few repo links
d30e126 Merge pull request #374 from RegusAl/patch-1
891150d Update readme.md
d8f4cc5 Changed broken header background image to suitable replacement from unsplash.com (foggy lake scene)

brique115@DESKTOP-K8FGOI8 MINGW64 ~/OneDrive/바탕 화면/gittest/gittest (dev)
$ git remote -v
origin  https://github.com/epikbb/gittest.git (fetch)
origin  https://github.com/epikbb/gittest.git (push)

 

 

brique115@DESKTOP-K8FGOI8 MINGW64 ~
$ cd 'C:\Users\leemi\git'

brique115@DESKTOP-K8FGOI8 MINGW64 ~/git
$ git remote show origin
fatal: not a git repository (or any of the parent directories): .git

brique115@DESKTOP-K8FGOI8 MINGW64 ~/git
$ cd 'C:\Users\leemi\git\project'

brique115@DESKTOP-K8FGOI8 MINGW64 ~/git/project (main)
$ remote show origin
bash: remote: command not found

brique115@DESKTOP-K8FGOI8 MINGW64 ~/git/project (main)
$ git remote show origin
* remote origin
  Fetch URL: https://github.com/epikbb/project.git
  Push  URL: https://github.com/epikbb/project.git
  HEAD branch: main
  Remote branch:
    main tracked
  Local branch configured for 'git pull':
    main merges with remote main
  Local ref configured for 'git push':
    main pushes to main (up to date)

'형상관리' 카테고리의 다른 글

[220520] 깃 연습  (0) 2022.05.20