Back-End TIL/Git, Github

220914 TIL - Git/GitHub

BEstyle 2022. 9. 14. 14:51

9월 14일

Git Bash Commands

cd = change directory (cd Documents/)

mkdir - make directory (mkdir Dev)

touch - make new file (touch readme.txt / touch .readme.txt <-숨긴파일) - 텍스트 기반만 만들 수 있다.

mv main.go src- move main.go to src sub directory

mv ../readme.txt . - move upper directory readme.txt to current directory

cp  main.go .. - copy main.go file to upper directory

cp main.go ./main-copy.go - copy main.go file to current directory as main-copy.go

rm users.db - remove users.db file

* - wildcard (asterisk)

rm *.go - remove all files containing .go

rm server.* - remove all files containing server.*

rm -r src - relete src directory recursively deleting all the files within

 

touch practice.md - create practice.md file

vim practice.md - vim edit practice.md file

:wq - write and quit (save and quit)

cat practice.md - read what's inside practice.md

최우영 강사님 pdf

 

 

 

Git status - On branch main ~~ meaning it is repository

* Under project name, need a line consisting description of the project.

 

$ git add README.md - stage에 올린다.

$ git Status

$ git commit - Commit need to have a proper title(1st line) and description (3rd line)

get a token

$ git push origin main - main = name of branch, origin = 원격 저장소의 주소(address of git clone)

* git remote add cat https://github.com/724thomas/first-repo.git 으로 하면 origin이 아닌 cat으로 push 가능

 

 

*두개의 파일을 수정하였을 경우,

작업단위를 구분해서/Commit을 따로 해야한다.

$ git add server.py

$ git add README.md

 

Cimmit을 할때 Conventional Rules are required  (*Differ by Teams)

최우영 강사님 pdf

 

새로운 하위폴더를 만들때는 push가 안되므로, ./220914-start-git.md 같이 만들면 된다.

또한, 같은 폴더에 두개의 파일을 add했을땐 status로 하나만 보인다.

this can be solved by $ git status -uall

 

 

 

 

Branch - 안전한 개발

$ git branch lunch

$ git switch lunch

$ git branch -D lunch - delete lunch branch

* 수정 후, Git add, Git commit을 하고 switch를 해야한다.

 

Merge Branch - lunch에서 main으로 가져오기

$ git merge lunch - main branch에서 실행.

$ git branch -D lunch - 합친 후, 삭제

 

 

Merge Conflict - Changes in both Main과 Branch then merge

* 같은 파일의 줄의 코드가 Conflict되면 

merge가 안되고, Main / Alter의 내용을 vi로 바꿔야한다.

 

 

 

 

 

 

 

 

BEst : 진도가 너무 빨라서 따라가기 힘들었다. 강의 설명으로는 부족해서 이해하려고 검색도 하면서 강의를 들었는데 중간중간 놓친것들이 꽤 있다.  ㅜ