본문 바로가기
Github 저장소

[Github 활용법] Ubuntu Git 설치 후 소스 파일 업로드하는 방법

by sangyeon 2021. 11. 5.
728x90

이번 글에서는 ubuntu linux 장비에서 git을 설치하고 소스 파일을 업로드 해보려 한다.

 

1. Ubuntu Linux Git 설치

root@master:~/source# sudo apt-get install git
Reading package lists... Done
Building dependency tree       
Reading state information... Done
git is already the newest version (1:2.25.1-1ubuntu3.2).
git set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 66 not upgraded.

 

2. Github 업로드

2-1. local repository 생성

> 소스를 업로드할 PC에서 소스코드가 있는 디렉토리로 이동한 뒤, git init 명령어로 local repository 설정을 해준다.

root@master:~/source# git init
Reinitialized existing Git repository in /root/source/.git/

 

2-2. local repository에 소스 추가

root@master:~/source# git add nginx-petclinic.zip
root@master:~/source# git add spring-framework-petclinic.zip 

 

2-3. commit 메세지 작성

> -m은 한 줄로 간단하게 메세지 작성할 때 사용하는 옵션

> local repo에 소스 파일 추가고 commit 하여 저장

root@master:~/source# git commit -m "docker-project"
[master (root-commit) 1d930d5] docker-project
 Committer: root <root@master.example.com>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

    git config --global --edit

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 2 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 nginx-petclinic.zip
 create mode 100644 spring-framework-petclinic.zip

 

2-4. remote repository 등록

> 소스 파일을 업로드할 remote repo를 지정한다.

> github 접속 > 프로젝트 > Code 에서 확인 할 수 있다.

root@master:~/source# git remote add origin "https://github.com/Hwang-sangyeon/Docker-Project.git"
root@master:~/source# 
root@master:~/source# git remote -v 
origin https://github.com/Hwang-sangyeon/Docker-Project.git (fetch)
origin https://github.com/Hwang-sangyeon/Docker-Project.git (push)

 

2-5. 소스 업로드 push

root@master:~/source# git push origin main
Username for 'https://github.com': sy9xxxxxx@gmail.com
Password for 'https://sy900511@gmail.com@github.com': 
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 2 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 1.99 MiB | 2.56 MiB/s, done.
Total 4 (delta 0), reused 0 (delta 0)
remote: 
remote: Create a pull request for 'master' on GitHub by visiting:
remote:      https://github.com/Hwang-sangyeon/Docker-Project/pull/new/master
remote: 
To https://github.com/Hwang-sangyeon/Docker-Project.git
 * [new branch]      master -> master

 



728x90