본문 바로가기
협업툴,가상환경 정리/Git관련

GitLab 사용법

by 알 수 없는 사용자 2022. 5. 17.

개념

출처 : https://wonhyeok1994.tistory.com/33?category=1057887

 


@@@는 알맞게 넣어줘야함

git cmd 창에서 활용함.

 

push든 pull 이든 어쨋든 첨에 git clone 으로 사용할 로컬저장소(git)와 클라우드저장소(github)를 연동해줘야함

한번만 clone 해주면 그담부턴 clone 안해줘도 된다.

 

push 하는법

1

git clone http://source.@본인주소@:9000/@본인닉네임@/@github프로젝트명@.git

 

2

(git CMD창에서)그다음 cd @github프로젝트명@ 쳐서 프로젝트 들어간 후,

 

3

코드수정~~~~ 후

 

4

git status 로 수정된 부분 확인 후

 

5

git add test/git_test.py 로 로컬저장소에 추가 ( git add . 으로 그냥 전체 추가도 가능 )

 

6

git status 로 확인해보면 로컬저장소 추가된 부분들은 초록색으로 뜬다.

 

7

git commit -m "git tutorial_1"    github(클라우드저장소)에 저장할때 같이 보낼 주석정도 라 생각하면 된다. 하고

 

8

git push origin main      으로 github(클라우드저장소)에 저장시키면 된다.

 

pull 하는법

1

push든 pull 이든 위에 git clone (1)번 한담에

 

2

git pull  하면 됨

 

 


 

 

Make new repo and push the existing code again to the new repo

git init doesn’t initialize if you already have a .git/ folder in your repository. So, for your case, do -

(1) rm -rf .git/
+ git rm -r --cached .
(2) git init

(3) git remote add origin http://본인주소~~~~~~~~~~

+ git config user.email "liam@메일주소.co.kr"
+ git config user.name "liam"

+ git add .

(4) git commit -m "git try again"

 

+ git branch    <-- 여기서 master 나오면 main으로 바꿔줘야한다.

+ git branch -M main

+ git branch    <-- main 확인

 

(5) git push -f origin main

Note that all git configs like remote repositories for this repository are cleared in step 1. So, you have to setup all remote repository URLs again.

Also, take care of the -f in step 5 : The remote already has some code base with n commits, and you’re trying to make all those changes into a single commit. So, force-pushing the changes to remote is necessary.

 

분수에맞게살자

그냥 빈 gitlab 을 git clone @@@ 떄린담에

git clone 된 폴더에 데이터 넣고 

git push 하셈

 

 

 

댓글