티스토리 뷰

2016/07/05 - [MyProject/Git Hub] - Git Hub 사용법 1 - Git Hub 이란??

2016/07/05 - [MyProject/Git Hub] - Git Hub 사용법 2 - Git Hub 가입하기

2016/07/06 - [MyProject/Git Hub] - Git Hub 사용법 3 - 깃헙 웹사이트 둘러보기

2016/07/10 - [MyProject/Git Hub] - Git Hub 사용법 4 - 콘솔용 Git 설치하기







1. Config


깃 콘솔을 설치했다면, 맥의 터미널을 열어 아래와 같이 타이핑하여 최초 설정을 완료해 주자.


1
2
[root@localhost earn_star]# git config --global user.name "ywlee861009"
[root@localhost earn_star]# git config --global user.email "ywlee861009@gmail.com"
cs


물론 "" 따옴표 안에는 자신의 이름과, 자신이 깃헙에 가입할 때 썼던 이메일 이어야 한다.

이것으로 최초 설정은 끝난다.








2. 온라인 저장소(Repo) 만들기


https://github.com 에서 아래와 같이 온라인 저장소를 만든다.












3. 로컬 저장소 만들기


온라인 저장소를 만들었으니, 내 pc 에서 온라인 저장소와 연결할 로컬 저장소를 만들어야 한다.

터미널을 열어 아래와 같이 타이핑하자.


1
[root@localhost phaser]# mkdir phaser_using_nodejs
cs


git에서 만든 프로젝트 이름으로 로컬 디렉토리를 하나 만들었다.


1
[root@localhost phaser]# cd phaser_using_nodejs/
cs


해당 폴더로 들어간다.


1
2
[root@localhost phaser_using_nodejs]# git init
Initialized empty Git repository in /home/yw/phaser/phaser_using_nodejs/.git/
cs


git init 을 타이핑하여 git 폴더로 사용할 것임을 알려준다.



이제, 아래와 같이 타이핑해보자.


1
2
3
4
5
6
[root@localhost phaser_using_nodejs]# git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)
cs


아무것도 없다.








4. 로컬 git 에 파일 추가하기


내 로컬폴더에서 아래와 같이 타이핑하여 "Readme.txt" 파일을 만들자.


1
[root@localhost phaser_using_nodejs]# touch Readme.txt
cs


다시 git status 를 타이핑해보자.


1
2
3
4
5
6
7
8
9
10
[root@localhost phaser_using_nodejs]# git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#    Readme.txt
nothing added to commit but untracked files present (use "git add" to track)
cs


아까완 다르게 Readme.txt 파일이 추가된 것을 볼 수 있다.

맨 아래줄을 보면, use "git add" 하라는 것이보인다..


설명대로 git add 를 해보자.


1
[root@localhost phaser_using_nodejs]# git add Readme.txt
cs


아무 반응이 없다.

다시 git status 를 쳐보자.


1
2
3
4
5
6
7
8
9
10
11
[root@localhost phaser_using_nodejs]# git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#    new file:   Readme.txt
#
 
cs


아까랑은 뭔가 달라졌다.

깃에 new file로 우리가 만든 리드미파일이 추가되었다.


 * 파일을 만든다고 git 에 자동으로 등록되는 것은 아니다.

   파일을 만들고, git 명령어를 통해 내 로컬 저장소로 먼저 업로드 한 후,

   온라인 저장소로 올려야 한다.


git commit 을 하여 내 로컬 저장소에 등록시켜보자.


1
2
3
4
5
[root@localhost phaser_using_nodejs]# git commit -"add Readme.txt"
[master (root-commit) 06af9fc] add Readme.txt
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 Readme.txt
 
cs


이제, 여기까지 하면, 내 로컬 git 저장소에 Readme.txt 파일이 추가된 것이다.


이제 온라인 저장소와 깃을 연결해서 파일을 추가해 보자.








5. 로컬 저장소와 온라인 저장소 연결하기


당연하게도 우리는 아직 로컬 저장소와 온라인 저장소를 연결하지 않았다.

이제 연결해보자.


다시, 깃헙 홈페이지로 돌아가서 우리가 만든 온라인 저장소로 들어가보자.




보이는 것처럼, 친절하게 설명되어있다.


..or create a new repository on the command line 을 보면, 

우리는 git commit 까지 했다.


이제, 저기 나온대로, git remote add origin 을 해보자.


1
[root@localhost phaser_using_nodejs]# git remote add origin https://github.com/ywlee861009/phaser_using_nodejs.git
cs


당연히, origin 뒤의 github url 은 당신의 온라인 저장소 이름을 입력해 줘야 한다.


이제 온라인 저장소와 로컬이 연결되었다.

파일을 올려보자.








6. git push


파일을 올리는 명령어는, 

git commit 으로 로컬 저장소까지 올라간 상태에서, 

git push 하는 것이다.


해보자.


git push -u origin master 


1
2
3
4
5
6
7
8
9
[root@localhost phaser_using_nodejs]# git push -u origin master
Username for 'https://github.com': ywlee861009@gmail.com
Password for 'https://ywlee861009@gmail.com@github.com'
Counting objects: 3, done.
Writing objects: 100% (3/3), 214 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/ywlee861009/phaser_using_nodejs.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.
cs








7. github.com 확인


github.com 온라인 저장소로 가서 올린 파일이 등록되었는지 확인해보자.




성공이당











공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함