-
유용한 git command 모음PROGRAMMING/Git 2021. 3. 25. 08:33반응형
Basic
// initialize project $ git init // download project $ git clone GIT_ADDRESS.git // stage a file $ git add FILE_NAME // stage all files from current folder $ git add . // commit to local storage $ git commit // commit to local storage by one line $ git commit -m "COMMIT MESSAGE" // push commits to remote storage $ git push origin master // save the current changes temporarily $ git stash
Advanced
// connect a local storage to a remote storage $ git remote add origin GIT_ADDRESS.git // force push $ git push -f origin master // force pull $ git fetch origin master $ git reset --hard FETCH_HEAD $ // if you want to what is deleted after clean, do "git clean -dn" first $ git clean -df // store your password $ git config credential.helper store --global // reset your password $ git config --system --unset credential.helper // merge recent 2 commits // pick : remain the commit, s : merge the commit with the picked commit $ git rebase -i HEAD~2 pick 004644d first commit s ae53bdf second commit // archive files which contain differences between commits // HEAD^ = HEAD ~ HEAD-1 $ git archive -o commit.zip HEAD $(git diff --name-only HEAD^) $ git archive -o commit.zip HEAD $(git diff --name-only f58725 56eb6a) $ // git reset --hard revert!! $ git reflog 1a75c1d... HEAD@{0}: reset --hard HEAD^: updating HEAD f6e5064... HEAD@{1}: commit: added file2 $ git reset --hard f6e5064 HEAD is now at f6e5064... added file2
Troubleshooting
만약 git reset --hard를 잘못 써서 이전 commit이 사라졌다면..!!! 😂😂 git reflog command를 이용한다.
stackoverflow.com/questions/5473/how-can-i-undo-git-reset-hard-head1
git commit 순서 섞기!
$ git rebase -i HEAD~#
http://minsone.github.io/git/git-reorder-commit
반응형'PROGRAMMING > Git' 카테고리의 다른 글
git을 이용한 깃허브(github) 연동하기 (0) 2017.08.03