don't stop believing

Gitlab 프로젝트 만들고 사용해 보기 본문

Tools/Git & GitLab

Gitlab 프로젝트 만들고 사용해 보기

Tongchun 2017. 11. 9. 11:32

GitLba 서버에 로그인합니다.

그리고 New project 버튼을 클릭해 새로운 프로젝트를 만들어 줍니다.

저는 Project name은 macaron-api로 하고 Visibility Level은 Public으로 해줬습니다.

그리고 Create project를 하면 생성됩니다.


Mac의 Terminal을 열고 git 연결을 하겠습니다. 먼저 적당한 곳에 프로젝트를 관리할 폴더를 만들어 줍니다.

참고로 프로젝트를 관리할 상단의 폴더입니다. git clone을 하면 프로젝트 이름으로 폴더가 생기는 것 참고 하세요.

$ cd Document
$ mkdir Macaron
$ cd Macaron

그리고 gitlab 써있는데로 Git global setup을 해줍니다.

$ git config --global user.name "tongchun"
$ git config --global user.email "tongchun@ngle.co.kr"

global 설정이 잘 되었는지 확인해 보니다.

$ git config --list
credential.helper=osxkeychain
user.name=tongchun
user.email=tongchun@ngle.co.kr

git clone으로 프로젝트를 가져옵니다.

$ git clone http://gitlab.ngle.co.kr/tongchun/macaron-api.git
Cloning into 'macaron-api'...
warning: You appear to have cloned an empty repository.

ls -al로 디렉토리를 확인하면 macaron-api 폴더가 생성된 것을 확인할 수 있습니다.

$ ls -all
total 0
drwxr-xr-x   3 appium  staff  102 11  9 11:59 .
drwx------+ 22 appium  staff  748 11  9 11:56 ..
drwxr-xr-x   3 appium  staff  102 11  9 11:59 macaron-api

macaron-api로 이동해서 README.md파일을 만들고 add, commit해 봅시다.

$ cd macaron-api/
$ touch README.md
$ git add README.md
$ git commit -m "add README"
[master (root-commit) 406b1fa] add README
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 README.md

commit된 README.md 파일을 gitlab으로 업로드 합니다. 업로드는 push 명령으로 하는데 Username과 Password를 물어봅니다.

$ git push -u origin master
Username for 'http://gitlab.ngle.co.kr': tongchun
Password for 'http://tongchun@gitlab.ngle.co.kr':
Counting objects: 3, done.
Writing objects: 100% (3/3), 212 bytes | 212.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://gitlab.ngle.co.kr/tongchun/macaron-api.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

Gitlab에 README.md파일이 잘 올라갔는지 확인해 봅시다.



이제 git을 사용하면서 기본적인 명령만 알면 바로 사용할 수 있습니다.

  • git add --all: 변경된 모든 파일을 내부 git repository에 추가합니다.
  • git commit -m "commit message": 내부 git repository에 커밋 메시지와 함께 커밋합니다.
  • git push -u origin master: GitLab에 commit된 내용을 업데이트 합니다.
  • git --all: git에 내장된 GUI를 실행해 확인합니다.


프로젝트에 멤버를 추가해 사용할 수 있습니다.



'Tools > Git & GitLab' 카테고리의 다른 글

git 기본 명령  (0) 2018.06.11
ssh key 생성하고 적용하기  (1) 2017.12.26
[GitLab] Backup & Restore  (0) 2017.09.04
[GitLab] 도메인 변경  (0) 2017.09.04
[GitLab] Ubuntu에 GitLab 설치  (0) 2017.08.30
Comments