[1] Git Study

Git

  • 가장 대중적인 코드 관리 도구
  • 목적 : 이력관리 (버전관리)
  • 특징 : ‘분산’ 버전관리

Git Setting

1
2
3
git config --global user.name "name"
git config --global user.email "email"
git init # After make a folder

Git Status

1
2
3
4
5
git status
git add 'file.type'
git commit 'file.type' -m "Your Message"
# git commit -m "Your Message" when you need all file commits

Staged File : Files requiring constant observation Commited File : Save current condition in Git Repo

  1. git status
  • Version Control, Source Code Management
  • When appears ‘Untracked file’. It means Git doesn’t know that file
  1. git add
  • 1st alert ‘Changes to be commit’. It means Your file is in Staged Area
  • 2nd alert ‘Changes not staged for commit’. It means You’ve got modified file on Tracked file, But not in Staged Area (Not Staged condition)
  1. git commit
  • Source Control is Available since data was committed in Git Repository
  • Enter when you want to SAVE

Git ignore

git mv file.rft file.gitignore

When you’ve got files you want to ignore, make a txt file and change file extention .rtf(.txt etc) to .gittgnore.

Git log - 기록

press ‘q’ when escape

1
2
3
4
commit a4d380ce1cf6e8866f0f1d07cfaa804083476e0c
Author: Name <your@email.com>
Date:   Wed Dec 11 100:00:00 2019 +0000

commit : Hash Code of your file Author : Author name <Author’s email> Date : Committed date

git log’s 4 command line

1
2
3
4
5
git log --status
git log --pretty=oneline
git log --pretty=format : "%h - %an, %ar : %s"
git log --pretty=format : "%h - %an, %ar : %s" --graph

Git checkout

Not a recommanded way git checkout 'hash[:6]' Keep returning purpose in mind

Branch

1
2
3
4
5

git branch # Expected Result with green font colour : * master
git branch 'name'
git checkout 'name' # Expecte

when you checking out to master, files you made with another branch name will disappear

Merge

git merge name # branch name in the master branch

gitk - History with graph

gitk

Push

git push -u origin master Branch called master push to Remote server called origin

Remote

Create New Repository on terminal line git remote add origin https://www.github.com/~/~ remote Total command line of remote repository add Plus origin the name, the first https://~ same as HTML

Remote Command Line

git remote #Expected Result : origin git remote -v git remote add origin git remote add name git remote rm name # Delete

Commit in Git Remote server

1
2
3
4
git add name
git commit name -m "Message"
git push origin master

Remote server to Local

  1. Clone - Get everything
  2. Pull - Merge same branch
  3. Fetch - Only get changed things

(1) Fork & Pull Request

Fork🍴 - 타인의 Repo를 나의 github repo로 옮김 Pull Request - Fork로 가져온 타인의 코드 수정 후 반영을 요청함

1
2
3
4
git pull address master # Easiest way
git fetch origin master # bring Latest version & can get another branch
git merget origin master

(2) Permission

permission Setting : 작업 권한을 공동 작업자에게 위임 github 내 setting 에서 추가

유튜브 Git - Teamlab 강의