글쓰는 개발자

[Git]Git-CLI 백업 with 생활코딩 - 3.push 본문

Development/Software Engineering

[Git]Git-CLI 백업 with 생활코딩 - 3.push

개발하자 2019. 6. 12. 19:51

원격 저장소를 지역 저장소와 연결하는 작업을 마쳤다.

서로를 연결하는 통로가 생겼으니, 이제 데이터를 주고받을 수 있는 단계가 된 것이다.

git을 사용하는데 있어서 가장 중요하고 기본적인 기능이다.

 

지역 저장소에서 commit을 하고 github에 업로드해보자.

./gitStudy$ git log --oneline --all

daa63a3 (HEAD -> master, origin/master) commit without File3
fea7dc5 Revert "Version2"
a23df4a Version2
bd66197 Version1

./gitStudy$ ls -al
total 24
drwxrwsr-x  3 cabox www-data 4096 Apr 29 07:13 .
drwxrwsr-x 11 cabox www-data 4096 Jun 10 07:49 ..
-rw-rw-r--  1 cabox www-data    4 Apr 29 07:13 File1.txt
-rw-rw-r--  1 cabox www-data    4 Apr 29 07:12 File2.txt
-rw-rw-r--  1 cabox www-data    4 Apr 29 07:12 File3.txt
drwxrwsr-x  8 cabox www-data 4096 Jun  8 22:27 .git

./gitStudy$ git status

On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   File3.txt

File3가 revert 버전에서 제외되었다.

./gitStudy$ git commit -am "File3 Readded"

[master b85bbb9] File3 Readded
 1 file changed, 1 insertion(+)
 create mode 100644 File3.txt
 
./gitStudy$ git push
Username for 'https://github.com': [User Id]
Password for 'https://github.com': [User Pw]
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 297 bytes | 297.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/wooyounggggg/studyRepo.git
   daa63a3..b85bbb9  master -> master

git push 명령어를 통해 github에 File3가 추가된 commit을 업로드하였다.

확인해보자.

5 commits 버튼을 클릭!

'File3 Readded' commit이 추가된 것을 확인할 수 있다.

 

이러한 방식으로, 일정 단위의 작업을 정해서 그 작업이 끝날 때마다 commit을 하고 github에 업로드해주면

클라우드 방식으로 git을 사용할 수 있다.

이제 이것을 다시 컴퓨터로 끌어올 수만 있게 되면, 우리는 어떠한 작업을 위해 한 컴퓨터에만 머무르는 것이 아니라

여러 환경/여러 PC를 옮겨다니며 동일한 작업을 이어나갈 수 있게 된다. 이것은 정말로 획기적이지 않을 수가 없다.

다음 포스팅은 원격 저장소의 commit을 다른 컴퓨터에 동기화시킬 수 있는 clone 및 pull에 대한 내용이 되겠다.

 

 

출처

생활코딩 GIT3 - CLI 백업 push

반응형
Comments