$ mkdir git-test && cd $_
$ echo "Hello World" > README.txt
$ cat README.txt
Hello World
$ git init
Initialized empty Git repository in C:/Users/r2com/git-test/.git/
$ git config --global user.email "test@example.com" # 버전 관리를 위해 내 정보 설정(필수)
$ git config --global user.name "seoes"
$ git add README.txt
$ git commit -m "add site" #하나의 작업 완료 후 git에서 관리해주는 소스파일 된 것
[master (root-commit) ee0b2d0] add site
1 file changed, 1 insertion(+)
create mode 100644 README.txt
$ echo "Aloha" >> README.txt
$ git add README.txt
$ git commit -m "add update"
[master 62b4357] add update
1 file changed, 1 insertion(+)
$ git log # 변동사항 보기
commit afa3c80a06aedb15746833e4e6406d93e5b9c8f5 (HEAD -> master)
Author: seoes <test@example.com>
Date: Tue Jul 26 09:46:57 2022 +0900
add update
commit 9f515fbdf1722246eeb7bfe34e41182276b6839a
Author: seoes <test@example.com>
Date: Tue Jul 26 09:42:42 2022 +0900
add site # 아래서부터 과거로 보여줌
$ git checkout 9f515fbdf1722246eeb7bfe34e41182276b6839a # 롤백
Note: switching to '9f515fbdf1722246eeb7bfe34e41182276b6839a'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at 9f515fb add site
$ cat README.txt
Hello World
$ git checkout - # 가장 최근으로 롤백
Previous HEAD position was 9f515fb add site
Switched to branch 'master'
$ git remote add origin https://github.com/seo369/test-dev.git
$ git push origin master
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (6/6), 436 bytes | 436.00 KiB/s, done.
Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/seo369/test-dev.git
* [new branch] master -> master
토큰 삭제
제어판 > 사용자 계정 > 자격 증명 관리 > Windows 자격 증명 > 해당 자격 증명 제거
토큰 생성
github > settings > Developer settings > Personal access tokens > Generate new token > 노트 : test-dev > repo 체크 > Generate token
$ git clone https://github.com/seo369/test-dev.git # 내려받기
Cloning into 'test-dev'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 6 (delta 0), reused 6 (delta 0), pack-reused 0
Receiving objects: 100% (6/6), done.
$ cd test-dev/
$ cat README.txt
$ echo "NIHAO" >> README.txt
$ git add README.txt # 수정하면 무조건(git add .도 가능; 2개이상일 경우)
$ git commit -m "add list"
$ git push origin master #이미지 다운
$ git pull origin master #master에서 바뀐내용 가져옴
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 238 bytes | 19.00 KiB/s, done.
From https://github.com/seo369/test-dev
* branch master -> FETCH_HEAD
afa3c80..d3d4496 master -> origin/master
Updating afa3c80..d3d4496
Fast-forward
README.txt | 1 +
1 file changed, 1 insertion(+)
$ git rm README.txt
rm 'README.txt'
$ git commit -m "remove README.txt"
[master ffbe436] remove README.txt
1 file changed, 3 deletions(-)
delete mode 100644 README.txt
$ git push origin master #제거하라는 명령 푸쉬
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (2/2), 197 bytes | 197.00 KiB/s, done.
Total 2 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/seo369/test-dev.git
d3d4496..ffbe436 master -> master
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
EXTERNAL_URL="http://192.168.0.188" yum install -y gitlab-ce # 내 ip
cat /etc/gitlab/initial_root_password # 패스워드 수정
Resiter Now
[root@localhost ~]# yum install -y git
[root@localhost git-test]# git init
Initialized empty Git repository in /root/git-test/.git/
[root@localhost git-test]# //git 버전관리를 위한.
[root@localhost git-test]# git config --global user.email "test@example.com"
[root@localhost git-test]# git config --global user.name "seoes"
[root@localhost git-test]# git add README.txt
[root@localhost git-test]# git commit -m "add site"
[master (root-commit) dac9a0b] add site
1 file changed, 1 insertion(+)
create mode 100644 README.txt
[root@localhost git-test]# echo "Aloha" >> README.txt
[root@localhost git-test]# git add README.txt
[root@localhost git-test]# git commit -m "add update"
[master 08dc1b2] add update
1 file changed, 1 insertion(+)
[root@localhost git-test]# git log
commit 08dc1b29560b8991d3243ec07c23040f46d47e4a
Author: seoes <test@example.com>
Date: Tue Jul 26 12:13:49 2022 +0900
add update
commit dac9a0b43d4b329859cb15073083e356f0b3500d
Author: seoes <test@example.com>
Date: Tue Jul 26 12:11:18 2022 +0900
add site
[root@localhost git-test]# git checkout dac9a //id 앞 5글자도 가능
Note: checking out 'dac9a'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at dac9a0b... add site
[root@localhost git-test]# cat README.txt
Hello World
[root@localhost git-test]# git checkout -
Previous HEAD position was dac9a0b... add site
Switched to branch 'master'
[root@localhost git-test]# cat README.txt
Hello World
Aloha
[root@localhost ~]# mkdir git-test && cd $_
[root@localhost git-test]# echo "Hello World" > README.txt
[root@localhost git-test]# git init
Initialized empty Git repository in /root/git-test/.git/ #초기화->로컬저장소
[root@localhost git-test]# git config --global user.email "test@example.com"
[root@localhost git-test]# git config --global user.name "seoes"
[root@localhost git-test]# git add README.txt
[root@localhost git-test]# git commit -m "add site"
[master (root-commit) c994a5c] add site
1 file changed, 1 insertion(+)
create mode 100644 README.txt
[root@localhost git-test]# echo "Aloha" >> README.txt
[root@localhost git-test]# git add README.txt
[root@localhost git-test]# git commit -m "add update"
[master 7029ed2] add update
1 file changed, 1 insertion(+)
[root@localhost git-test]# git log
commit 7029ed257b4074b7b5140cdef684b31154aab908
Author: seoes <test@example.com>
Date: Tue Jul 26 14:13:31 2022 +0900
add update
commit 2ea247467c6f59e54fbeaa04fd4da8f5cf6f3f6a
Author: seoes <test@example.com>
Date: Tue Jul 26 14:12:34 2022 +0900
add site
[root@localhost git-test]# git checkout 2ea24
Note: checking out '2ea24'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at 2ea2474... add site
[root@localhost git-test]# cat README.txt
Hello World
[root@localhost git-test]# git checkout -
Previous HEAD position was 2ea2474... add site
Switched to branch 'master'
[root@localhost git-test]# git remote add origin http://192.168.0.188/seoes/test-project.git
[root@localhost git-test]# git branch -M main
[root@localhost git-test]# git push -uf origin main
Username for 'http://192.168.0.188': seoes
Password for 'http://seoes@192.168.0.188':
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (6/6), 435 bytes | 0 bytes/s, done.
Total 6 (delta 0), reused 0 (delta 0)
To http://192.168.0.188/seoes/test-project.git
+ b75b083...7029ed2 main -> main (forced update)
Branch main set up to track remote branch main from origin.
$ git clone http://192.168.0.188/seoes/test-project.git
Cloning into 'test-project'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (6/6), done.
$ cd test-project/
$ cat README.txt
Hello World
Aloha
$ echo "NIHAO" >> README.txt
$ git add README.txt
warning: in the working copy of 'README.txt', LF will be replaced by CRLF the next time Git touches it
$ git commit -m "add list"
[main a4591bf] add list
1 file changed, 1 insertion(+)
$ git branch -M main
-> 로그인하면 bash화면이 이렇게 바뀜
$ git push -uf origin main
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 258 bytes | 258.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To http://192.168.0.188/seoes/test-project.git
7029ed2..a4591bf main -> main
branch 'main' set up to track 'origin/main'.
CICD
delivery 수동
deployment 자동
트리거 반드시 필요 (변동사항 발생시 트리거)
젠킨스 = 컨트롤타워?, 크론을 이용