Upstage AI Lab 2기
2024년 1월 15일 (월) Day_024
Day_024 실시간 강의 : git
(패스트캠퍼스 최우영 강사님)
1. Create New repo 'branch-practice' (README.md, MIT)
1-1. .gitignore(OS, python, vim) (https://www.toptal.com/developers/gitignore/)
2. clone repo (~/Documents/dev/)
3. Create new file 'main.py'
4. add, commit, push
$ git clone (githuburl)
hyj89@BOOK-UMAV30Q2HQ MINGW64 ~/Documents/dev
$ git clone https://github.com/Hye-yoonJeong/brach-practice.git
Cloning into 'brach-practice'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (6/6), done.
$ ls
hyj89@BOOK-UMAV30Q2HQ MINGW64 ~/Documents/dev
$ ls
Hye-yoonJeong/ brach-practice/ gh-blog/ my-first-repo/
README.md examplecommits/ main.py
$ cd brach-practice/
# brach-practice (main)
$ touch main.py
$ git add main.py
$ git status
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: main.py
$ git commit
$ git status
On branch main
Your branch is ahead of 'origin/main' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
$ git push origin main
umerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 16 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 310 bytes | 155.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/Hye-yoonJeong/brach-practice.git
b095802..b5604dd main -> main
$ git status
On branch main
Your branch is up to date with 'origin/main'.
nothing to commit, working tree clean
$ git branch
* main
$ git branch -r
origin/HEAD -> origin/main
origin/main
$ git remote -v
origin https://github.com/Hye-yoonJeong/brach-practice.git (fetch)
origin https://github.com/Hye-yoonJeong/brach-practice.git (push)
$ git branch -a
* main
remotes/origin/HEAD -> origin/main
remotes/origin/main
$ git branch lotto
$ git branch
lotto
* main
commit ID 확인하는 명령어
$ git lg
commit ID를 이용해 분기점 switch
$ git swith lotto
Switched to branch 'lotto'
# branch 삭제 명령어
git branch -D
$ vi main.py
$ cat main.py
from random import sample
print(sample(range(1, 45+1), k=6))
$ python main.py
[29, 7, 23, 13, 39, 1]
$ git status
On branch lotto
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: main.py
no changes added to commit (use "git add" and/or "git commit -a")
$ git add main.py
$ git commit
[lotto f60fd48] feat: Get 6 Random Integers Using random.sample()
1 file changed, 3 insertions(+)
$ git status
On branch lotto
nothing to commit, working tree clean
$ git switch main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
$ cat main.py
$ python main.py
-> branch 나눈 이후 작업했기 때문에 main branch 상에는 아무 변화 없음
$ git switch lotto
$ python main.py
[5, 10, 34, 1, 36, 17]
$ vi main.py
$ cat main.py
from random import sample
def get_luckies() -> list:
return sample(range(1, 45+1), k=6)
if __name__ =='__main__':
print(get_luckies())
$ git add main.py
$ git status
On branch lotto
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: main.py
$ git commit
[lotto f88093c] feat: Define Feature get_luckies()
1 file changed, 5 insertions(+), 1 deletion(-)
$ git branch
* lotto
main
$ git switch main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
$ git merge lotto
Updating b5604dd..f88093c
Fast-forward
main.py | 7 +++++++
1 file changed, 7 insertions(+)
$ python main.py
$ cat main.py
from random import sample
def get_luckies() -> list:
return sample(range(1, 45+1), k=6)
if __name__ =='__main__':
print(get_luckies())
$ git branch
lotto
* main
$ git branch -D lotto
Deleted branch lotto (was f88093c).
$ git branch
* main
$ git branch alt-lotto
$ git branch
alt-lotto
* main
$ cat main.py
git rebase
$ git branch
* main
$ git branch rebase-practice
$ git branch
* main
rebase-practice
$ vi main.py
(change element : pineapple -> kiwi)
$ git status
On branch main
Your branch is up to date with 'origin/main'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: main.py
no changes added to commit (use "git add" and/or "git commit -a")
$ git add main.py
$ git commit
[main 3b5b0d0] feat: Change Element
1 file changed, 1 insertion(+), 1 deletion(-)
$ git switch rebase-practice
hyj89@BOOK-UMAV30Q2HQ MINGW64 ~/Documents/dev/brach-practice (rebase-practice)
Switched to branch 'rebase-practice'
$ git branch
main
* rebase-practice
$ vi main.py
(add element : steak)
$ git status
On branch rebase-practice
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: main.py
no changes added to commit (use "git add" and/or "git commit -a")
$ git add main.py
$ git commit
[rebase-practice ad42678] feat: Add Element
1 file changed, 1 insertion(+)
$ git rebase main
Successfully rebased and updated refs/heads/rebase-practice.
$ cat main.py
from random import randint
from random import choice
def get_randint() -> list:
return [randint(1,50) for _ in range(7)]
def get_choice() -> list:
return [choice(range(1, 50+1)) for _ in range(7)]
fruits = [
'apple',
'banana',
'kiwi',
]
foods = [
'pasta',
'pizza',
'stew',
'steak',
]
if __name__ =='__main__':
print(get_randint())
print(get_choice())
$ git status
On branch rebase-practice
nothing to commit, working tree clean
$ git switch main
Switched to branch 'main'
Your branch is ahead of 'origin/main' by 1 commit.
(use "git push" to publish your local commits)
$ git branch
* main
rebase-practice
$ git branch -D rebase-practice
Deleted branch rebase-practice (was d836fb8).
$ git branch
* main
$ cat main.py
from random import randint
from random import choice
def get_randint() -> list:
return [randint(1,50) for _ in range(7)]
def get_choice() -> list:
return [choice(range(1, 50+1)) for _ in range(7)]
fruits = [
'apple',
'banana',
'kiwi',
]
foods = [
'pasta',
'pizza',
'stew',
]
if __name__ =='__main__':
print(get_randint())
print(get_choice())
'Upstage AI Lab 2기' 카테고리의 다른 글
Upstage AI Lab 2기 [Day026] 실시간 강의 - 통계 (1) 통계 톺아보기 (0) | 2024.01.17 |
---|---|
Upstage AI Lab 2기 [Day026] 온라인 강의 - 기초통계 (2) (0) | 2024.01.17 |
Upstage AI Lab 2기 [Day015-022] EDA 조별 프로젝트 (5) 설명변수 조합 (0) | 2024.01.09 |
Upstage AI Lab 2기 [Day015-022] EDA 조별 프로젝트 (4) 가설 설정 (0) | 2024.01.08 |
통계학 복습 (0) | 2024.01.06 |