본문 바로가기
centos7

centos7 gitlab

by 이농이능 2018. 1. 16.


gitlab 사용법


git config --global user.name "이름"
git config --global user.email "이메일"

Create Repository(저장소 만들기)

mkdir 프로젝트이름
cd 프로젝트이름
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@gitlab.com:demun/저장소이름.git
git push -u origin master



출처: http://demun.tistory.com/2431 [demun(대문블로그)]






출처 https://www.zerocho.com/category/Git/post/581042fdcae2d100152ceae6

git remote

이제 다시 명령 프롬프트를 켜서 프로젝트 폴더로 갑니다. git remote가 바로 원격 저장소를 관리할 수 있는 명령어입니다. git remote add origin https://github.com/[이름]/gitExample로 origin이라는 이름으로 원격 저장소 주소를 등록합니다. 이제부터 origin이라는 이름을 사용하면 방금 전에 우리가 만든 저장소에 접속할 수 있습니다. (굳이 origin이라고 안 하고 다른 이름으로 해도 됩니다.) 만약 origin이라는 원격 저장소를 지우고 싶다면 git remote remove origin하면 됩니다.


git push

이제 원격 저장소와도 연결했으니 원격 저장소에 commit을 저장해봅시다. git push origin master 해보세요. origin은 원격 저장소 이름이고, master은 현재 사용하는 컴퓨터의 브랜치 이름입니다. 전 강좌에 on branch master 이라는 메세지를 보셨죠? 브랜치는 조금 있다 배우니까 지금은 master가 현재 commit이 저장된 곳이라고만 알아두세요.

로그인 하라고 뜰텐데 아까 만든 깃허브 계정으로 로그인 하면 push가 완료됩니다


git pull

git pull은 다른 사람이 PR을 통해서 코드를 업데이트했거나, 아니면 Github를 통해서 commit했을 때(Github를 통해서도 간단한 commit을 할 수 있습니다) 그 내용을 클라이언트로 내려받는 명령어입니다. git pull origin master 하면 origin의 내용이 master로 복사됩니다.

git clone

git clone은 git pull과 비슷하지만 클라이언트 상에 아무것도 없을 때 서버의 프로젝트를 내려받는 명령어입니다. git clone [저장소 주소] 를 하면 됩니다. 저장소의 내용을 다운로드받고 자동으로 init도 됩니다. 





원격 저장소 URL 변경하기

기존 원격 저장소 URL을 변경하기 위해 git remote set-url 명령어를 사용합니다:

$ git remote -v
 	# View existing remotes
origin  https://github.com/user/repo.git (fetch)
origin  https://github.com/user/repo.git (push)

$ git remote set-url origin https://github.com/user/repo2.git
# Change the 'origin' remote's URL

$ git remote -v

# Verify new remote URL
origin  https://github.com/user/repo2.git (fetch)
origin  https://github.com/user/repo2.git (push)