Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

개발자되기 프로젝트

Git? Git Hub?? 사용하기 본문

Git & Git Hub

Git? Git Hub?? 사용하기

Seung__ 2021. 6. 26. 17:52

1. Git


   Configuration Management Tool(형상관리 도구) 중 하나이다.

   Version Control Syhstem(버전 관리도구) 중 하나이다.

 

   회사나 학교에서  ppt로 예를들면 xxxx자료_v1, xxxx자료_v2, xxxx자료_v3  주절주절 계속 만든다.

 

   이러한 방식은 문제가 많다.. v3열려다가 아무생각없이 v2열어서 수정해서 필요한 정보가 날라가기도 한다.

 

   이런 사태를 피하고자 별도 폴더를 만들어서 각 파일을 따로 격리시키는것도 노답이다.

 

   git은 각 파일의 버전을 snap shopt을 찍어 분산하여 관리하도록 도와준다.

 

  즉 내가 맨날 그리는 도면으로 생각하면 CDM에 도면을 REV마다 등록한다고 볼 수 있다.

 

 

2. 분산모델


  git은 하나의 중앙 서버가 존재하지만,

  여러 client들은 각자의 local에서 중앙 서버의 사본을 가지고 작업을 한다.

 

 

 

3. Git 설치하기


  1) git에서 직접 설치 https://git-scm.com/downloads

 

Git - Downloads

Downloads macOS Windows Linux/Unix Older releases are available and the Git source repository is on GitHub. GUI Clients Git comes with built-in GUI tools (git-gui, gitk), but there are several third-party tools for users looking for a platform-specific exp

git-scm.com

 2) cmder 설치(window) : https://cmder.net/

 

Cmder | Console Emulator

Total portability Carry it with you on a USB stick or in the Cloud, so your settings, aliases and history can go anywhere you go. You will not see that ugly Windows prompt ever again.

cmder.net

   윈도우 기본 cmd보다 조금더 이쁘고, full버전에는 git이 포함되어 있어 별도로 설치가 필요 없다.

 

 

4. 설치 확인하기


  설치가 정상적으로 되었으면 git --version 명령어를 통해 현재 버전 확인이 가능하다.

C:\Git_Tutorial\Git-Tutorial (master -> origin)
λ git --version
git version 2.29.1.windows.1

 정상적으로 잘 설치되었따~

 

 기타 다른 명령어를 보려면 git --help

 

 

5. 그럼 Github은 뭐임?


Github는 Git 원격 저장소를 제공해는 web service이고, git 서버 관리를 대신 해주는 등 여러 기능을 제공해준다.

 

 

6. Git Hub에서 repository 만들기


 

  Repository 이름을 지정하고 공개여부를  체크한다.

  gitignore(설정파일을 추가할지), license관련한 설정을 확인해주면 끝

   Repository 가 생성되면 접근 가능한 주소를 확인할 수 있다.
   https://github.com/bsh6463/Git-Tutorial.git

 

 

7. Git ~ Github 연결하기


1) 먼저 git에 GitHun의 id와 email을 등록해주자.

  git config --global user.name bsh6463 
  git config --global user.email bsh9510@gmail.com

사용할 준비가 되었다.

 

먼저 local에서 사용할 폴더를 하나 만들어 주자.

C드라이브에 Git_Tutorial 폴더를 만들었고 이 폴더에 git 저장소를 그대로 다운로드 받아서

git hub와 컴퓨터를 일종의 동기화를 시켜서 컴퓨터에 올리는 파일이 git hub의 저장소로 올라가도록 할 것이다.

 

2) 사용할 폴더로 이동하기

우리가 사용할 C:\Git_Tutorial 경로로 이동하자. cd는 change directory을 의미.

cd C:\Git_Tutorial

 

3) git clone

repository의 주소로 접근해서 clone을 한다.

C:\Git_Tutorial
λ git clone https://github.com/bsh6463/Git-Tutorial.git
fatal: destination path 'Git-Tutorial' already exists and is not an empty directory.

(이미 한번 만들어둬서 Git-Tutorial 이 존재한다고 경고가 떴다.)

 

여기까지 하면 project를 컴퓨터로 클론을 해준 것이다.

  - 컴퓨터 : local repository

  - git hub repository : remote repository

 

 

8. file올리기


 

 Git-Tutorial 폴터에 document.txt를 만들고 github에 올려보자.

 

 

자 그러면 이제 새로운 변경사항을 알려주기 위해서 해당 파일을 git project로 등록이 필요하다.

 

 1) C:\Git_Tutorial\Git-Tutorial 경로로 이동하자.

C:\Git_Tutorial
λ cd C:\Git_Tutorial\Git-Tutorial

C:\Git_Tutorial\Git-Tutorial (master -> origin)
λ

2) 그 다음 document.txt파일을 업로드를 하기 위해 git add

C:\Git_Tutorial\Git-Tutorial (master -> origin)
λ git add document.txt

3) commit

   commit을 통해 실제로 파일이 업로드가 된 시점을 스냅샷 찍어둠.

   commit message와 함께 실행이 가능하다.

C:\Git_Tutorial\Git-Tutorial (master -> origin)
λ git commit -m "Add Text File [document.txt]"
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

아무것도 수정을 안해서 별 내용이 없다. 

 

txt파일 내용을 살짝 수정 후 다시 해보자.

C:\Git_Tutorial\Git-Tutorial (master -> origin)
λ git add document.txt

C:\Git_Tutorial\Git-Tutorial (master -> origin)
λ git commit -m "Add text file [document.txt]"
[master 7af6358] Add text file [document.txt]
 1 file changed, 3 insertions(+), 1 deletion(-)

요기 까지 하면 local repository에는 반영이 되었으나, git hub에는 반영이 되지 않은 상태이다.

 

4) git push

  git push를 통해 실제로 git hub에 등록이 가능하다.

C:\Git_Tutorial\Git-Tutorial (master -> origin)
λ git push
Username for 'https://github.com': bsh6463
Password for 'https://bsh6463@github.com':
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 287 bytes | 287.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/bsh6463/Git-Tutorial.git
   09c7e9b..7af6358  master -> master

수정한 파일이 잘 올라간 것을 확인이 가능하다.

 

commit실행 시 추가한 message가 표기된 것도 볼 수 있다.

history도 확인이 가능하다.

Comments