728x90
반응형
# initialize github
git init
# check
git status
# check
git config
# set config
git config --global user.name {NAME}
git config --global user.email {EMAIL}
git config --global core.editor "vi"
# create text file
echo "hell git" > file.txt
# check file lists in the current directory
ls
# check status, there should be "untracked"
git status
# add "file.txt" in waiting list for push
git add file.txt
# checck status, "file.txt" should be in the list of "Chnges to be committed"
git status
# Unstage file.txt
git reset file.txt
# check status, "file.txt" should be in the list of "Untracked files"
git status
# add "file.txt" in waiting list for push
git add file.txt
# checck status, "file.txt" should be in the list of "Chnges to be committed"
git status
# commit, when it opens "editor", type any comment and then save it.
# Then, there should be "[master (root-commit) cf61bc5] test // 1 file changed, 1 insertion(+)"
git commit
# checck status, there should be "On branch master nothing to commit, working tree clean"
git status
# Check commit, there should be "* cf61bc5 (HEAD -> master) test"
git log --oneline --graph --all --decorate
# connect to github repository
git remote add origin {repository}
git remote -v
https://sowon-dev.github.io/2021/05/09/210510git-connectProject/
# master 를 main으로 바꾸고 시작하기
git branch main
git checkout main
git branch -d master
# 브랜치 뭐뭐 있는 지 확인
git branch
# push, there should be ERROR
# git push --set-upstream origin master
# 로컬장소의 [master] 브랜치와 연결된 원격저장소의 브랜치가 없어서 발생한 오류.
# upstream 브랜치는 로컬저장소와 연결된 원격저장소.
# 이를 해결하기 위해서 --set-upstream을 쓰거나 -u를 쓴다. 그러면 이후에는 git push 만으로도 에러 없이 push가 가능해진다.
git push
# push와 동시에 upstream 지정
git push --set-upstream origin master
# 브랜치 생성
# check the current branch, * points the current branch that we are in
git branch
# create branch
git branch {NAME}
# checkout to another branch
git checkout {NAME}
# check the curretn branch
git branch
# add more line in file.txt
echo "second" >> file.txt
# check status, file.txt should be under "modified"
git status
# commit file.txt
git commit
# check log
git log --oneline --all
#### result
# 26b6d59 (HEAD -> dmserver3) hey
# cf61bc5 (origin/master, master) test
#### result
# checkout to master
git checkout master
# merge commit
git merge dmserver3
# reset
git reset --hard {이동할 commit 체크섬}
728x90
반응형