시스템 분석 설계

GIT

blackbearwow 2022. 5. 22. 01:07

1. git-scm다운로드

리눅스 운영체제에서는 apt install git을 하면 git명령을 할 수 있게 되지만, windows에서는 따로 설정해주어야 한다.

https://git-scm.com/downloads 사이트에서 다운받아 설치한다.

 

2. git config

cmd창에 user.name과 user.email을 설정한다. --global은 ~/.gitconfig에 저장된다.

git config --global user.name BlackBearWow
git config --global user.email pat0407@naver.com

repository에 따로 config하고싶다면 --global대신에 --local을 한다. --local은 생략 가능하다. --local은 .git/config에 저장된다.

git config --local user.name crossSiteKikyo
git config --local user.email patmailaddress01@gmail.com

 

잘 config되었는지 보는 명령어. 

git config list

3. git 주요 명령어

명령어 설명
git clone {url} {folder name} github에 있는 레포지토리를 현재 디렉토리에 복사하여 folder name으로 생성하여 다운한다. folder name은 생략 가능하다.
git status 현재 git의 상태를 보여준다.
git log git의 commit 로그를 보여준다.
git add . 현재 디렉토리의 변경된 것들을 모두 staging area로 적용한다.
git commit -m "message" staging area에 적용된 것들을 local repository에 적용한다.
git push local repository에 적용된 것들을 remote repository에 적용한다.
git pull git fetch와 git merge를 합쳐서 git pull이다.

 

https://ndb796.tistory.com/187

4. .gitignore파일

.gitignore파일을 만들어 git add 를 해도 Staging Area에 추가되지 않는 폴더나 파일을 정의한다.

[folder name]/

특정 폴더 전체를 무시할 경우

[file name]
[folder name]/[file name]

특정 파일을 무시할 경우

*.[확장자]
??.jpg

*는 /를 제외한 모든것, ?는 /를 제외한 하나의 문자를 의미한다.

루트 디렉토리에서 특정 확장자인 파일을 무시한다는 의미.

.jpg이고 두 문자로 이루어진 파일을 무시한다는 의미.

# comment

#으로 시작하는 줄은 주석을 의미한다.

5. ssh방식으로 pull push하기

https://dc-choi.tistory.com/27

 

[Git] Ubuntu 환경에서 SSH를 이용하여 Push하기

Linux 환경에서 Git을 이용해서 원격 저장소에 Push를 해야하는 경우가 있다... 이제 Password를 사용해서 push를 하는것이 불가능해서 토큰을 받아서 push를 해야한다고 한다. 근데 이게 매번 토큰을 발

dc-choi.tistory.com

5.1. 여러 ssh키를 사용할 때 원하는 ssh키 사용법

ubuntu에서는 ssh를 사용하여 git push pull을 하는데, 여러 계정을 사용한다면 레포지토리마다 사용할 ssh를 다르게 해야 한다.

~/.ssh/config를 편집한다.

# BlackBearWow
Host BlackBearWow-github
        HostName github.com
        User git
        IdentityFile ~/.ssh/id_rsa

# crossSiteKikyo
Host crossSiteKikyo-github
        HostName github.com
        User git
        IdentityFile ~/.ssh/id_rsa2

그리고 레포지토리에서 별칭을 사용하여 remote url을 설정한다.

 

BlackBearWow 레포지토리

git remote set-url origin git@BlackBearWow-github:BlackBearWow/repository_name.git

crossSiteKikyo 레포지토리

git remote set-url origin git@crossSiteKikyo-github:crossSiteKikyo/repository_name.git

'시스템 분석 설계' 카테고리의 다른 글

플로우차트(흐름도, 순서도) flow chart  (0) 2022.05.09