본문 바로가기
카테고리 없음

[Git] xshell ubuntu 에서 github repository 연결 remote / commit/ push

by yo.na 2022. 2. 25.

환경 : window / xshell / ubuntu 에서 진행

 

1. 본인 github 에서 gitops 로 repository 생성

 

2. gitops repository 와 연결할 폴더 생성 / 올리고싶은 파일 추가

$ mkdir -p yeonhaaa/gitops

$ cd yeonhaaa/gitops

$ vi nginx-deploy.yaml

$ vi nginx-svc.yaml

 

 

3. gitops repository 연결(Remote) / Commit / Push

// README.md 파일 추가 -> 없으니까 오류났음 
$ echo " # GitOps" >> README.md

$ git init

$ git config --global user.email "이메일주소"

$ git config --global user.name "본인이름(이니셜)"

$ git config credential.helper store

$ git add .

$ git status  
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached ..." to unstage)
new file:   README.md
new file:   nginx-deploy.yaml
new file:   nginx-svc.yaml

이제 커밋, 푸시하러 가보자

$ git diff

$ git config --list

$ git commit -am "커밋메세지"     // m 옵션으로 커밋메세지추가 

$ git remote add origin 연결하고싶은git repository주소적기 

$ git branch -M main

$ git push -u origin main

Username : github username 적기 
Password : github에서 발급받은 access_token복붙

// 이렇게 뜨면 push 완료!
To https://github.com/yeonhaaa/gitops.git
 * [new branch]      main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.

github 가서 확인해보기!