본문 바로가기
Service/Git & GitHub

Introduction to Git and Github - Week 3

by 포항돼지 2022. 2. 18.

Working with remotes -> Github 쓰면 가능

각각 개발자들이 로컬에 git 을 두고 중간에 upload 하는거를 remote 라고 함 -> 이 작업을 통해, 다른 개발자들이 server에 접근해서 코드를 real time 으로 sync 하고 뭐 하는식 으로 일을 함

 

Github

저렇게 내 로컬컴퓨터를 쉐어 서버로 두려면, 호스팅 해야되고 하니까 귀찮아서 github라는 서로 git을 공유 하는 centeral server service 가 나옴

github에서 코드 가져와서 내 로컬 컴퓨터로 돌리는식

 

bitbucket or gitlab 같은 비슷한게 많음

repository size에 따라 돈 charging 함

 

github account 만든다음, 내 repo 만들어서 코드 쉐어하고, 다른 애들꺼 보고 하는거

 

Basic interaction with github

git clone URL 써가지고, github에 올라와있는 repo 내 local 에다가 다운

READmd (Mark down file)

 

수정하고 commit 해봄, github에 올리려면 git push 써야함
이렇게 github에 put하면
이렇게 github에 올라간걸 볼수 있음

 

계속 패스워드 치는거 귗낳으면,

 

-SSH key-pair 쓰거나,

-Credential helper 

쓰면됨 -> 그냥 activate 시키면됨 (git config --global credential.helper cache)

15분 동안 cache에 저장함

-git pull

 

CommandExplanation & Link

git clone URL Git clone is used to clone a remote repository into a local workspace
git push Git push is used to push commits from your local repo to a remote repo
git pull Git pull is used to fetch the newest updates from a remote repository

 

remote로 관리하는, 원격으로 관리하는 github repo 중에 fetch URL이랑 push URL 이 다를수 있다. read only 로 fetch 하는건 http 쓸수도있고, push 하는건 SSH나 HTTPS로 설정해놓으면 그렇게 됨

fetch랑 pull의 다른점은 fetch는 그냥 알려만 주는거,

pull은 실제로 가지고 오는거

 

원격 remote origin repo를 보여주ㅜㅁ

 

local out of date == update 가 있따고 알려주는거임

이럴때 git fetch command 써야됨

 

보면 remote origin repo에 비해 우리 local commit 이 하나 뒤쳐진거 확인 가능함

이때 remote branch 랑 local branch merge 시켜야함

merge 하려면 git pull 써도 됨

 

 

git fetch 는 review the changes that happen in the remote repository

git pull == fetching 한다음 instantly merge 시키는 command 임

output을 보면 git fetch output 이랑 git merge output 이랑 두개다 나오는걸 볼수 있음
동료가 github에 new branch commit 한거 확인
git checkout branch 해서 access 가능

 

CommandExplanation & Links

git remote  Lists remote repos
git remote -v List remote repos verbosely
git remote show <name> Describes a single remote repo
git remote update Fetches the most up-to-date objects
git fetch Downloads specific objects
git branch -r Lists remote branches; can be combined with other branch arguments to manage remote branches

An explicit merge creates a new merge commit. This alters the commit history and explicitly shows where a merge was executed.

 

git fetch will download remote updates, such as objects and refs, from the remote branch.

 

If you want to see more information about a particular remote branch, you can use the git remote show command. Don't forget the commit ID!

 

git remote update will fetch the contents of all remote branches and allow us to merge the contents ourselves.

 

 

 

remote에 있는데 local branch에 없으면 push 불가능

그래서 git pull 이나 fetch, merge 먼저해서 push 해야함

근데, merge confliction 이 있는경우, 고치고, merge한다음, push 가능

 

로그보면 Three way merge 한거 볼수있음

 

Pushing remote branches

브런치 만들고, 푸쉬하면됨

git checkout -b  refactor

-u == upstream 써가지고 origin repo에 new branch update

git Rebase

그냥 옛날껄로 돌린다고 생각 하면 편함

 

This makes debugging easier and prevents three-way merges by transferring the completed work from one branch to another.

 

git rebase is useful for maintaining a clean, linear commit history.

 

 

wound == 상처, 부상

implicit == 암시된, 내포된

verbosely == 장황하게

fetch == 가지고 오다, 불러오다

explicit == 분명한, 명쾌한

 

'Service > Git & GitHub' 카테고리의 다른 글

Introduction to Git and Github - Week 4  (0) 2022.02.20
Introduction to Git and Github - Week 2  (0) 2022.02.16
Introduction to Git and Github - Week 1  (0) 2022.02.16