$ git commit --amend$ git rebase -i HEAD~3pick ... pick ... pick ...
edit ... pick ... pick ...
$ git rebase -i HEAD~3
Stopped at 7482e0d... updated the gemspec to hopefully work better
You can amend the commit now, with
git commit --amend
Once you’re satisfied with your changes, run
git rebase --continue
git commit --amend 으로 메시지를 변경하고 git rebase --continue로 rebase를 계속한다. 이것을 반복하면 어떤 위치의 커밋 메시지도 수정할 수 있다. 다시 말하지만 주의할 점은 이미 서버에 push된 커밋은 rebase를 하면 SHA-1 값이 바뀌기 때문에 동료 개발자들을 혼란스럽게 할 가능성이 있다. 될 수 있으면 수정하지 말아야 한다.$ git rebase -i HEAD~3pick b pick c pick d
pick b squash c squash d
error: cannot 'squash' without a previous commit$ git log -p <브랜치이름>$ git log -p <브랜치이름> -- <파일/경로/이름.cpp>$ git show$ git show 커밋해시값$ git show HEAD$ git checkout -b <new-branch>checkout -b는 git branch <new-branch> 브랜치를 만들고, git checkout <new-branch> <new-branch> 브랜치로 이동하는 것과 동일함.$ git branch --contains <commit-id>$ git branch -a --contains <commit-id>git checkout developgit merge --no-ff <branch-name>git merge --no-ff <commit-id>--no-ff flag prevents git merge from executing a "fast-forward" if it detects that your current HEAD is an ancestor of the commit you're trying to merge.<<<<<<< HEAD ... ======= ... >>>>>>> <this-branch> changes
$ git add <conflict-files>$ git commit -m 'Fix conflict'$ git merge --no-commit--no-ff 와 같이 사용할 수 있다.$ git merge --no-ff --no-commit$ git stash$ git stash list$ git stash pop$ git stash apply
$ git stash list
stash@{0}: WIP on master: 049d078 added the index file
stash@{1}: WIP on master: c264051 Revert "added file_size"
stash@{2}: WIP on master: 21d80a5 added number to log
$ git stash drop stash@{0}
Dropped stash@{0} (364e91f3f268f0900bc3ee613f9f733e82aaed43)
$ git stash cleargit tag v1.0.0으로 현재 커밋에 태그를 다는 것이 더 일반적이다.git tag는 특정 커밋에 대해 레이블을 지정하여 태그를 붙이는 기능이다. 이를 사용하여 특정 커밋의 버전을 명시할 수 있다.$ git tag -ntag는 기본 git push에는 포함되지 않기 때문에 따로 명령을 써야 한다.$ git push origin v1.0$ git push origin --tags$ git push --follow-tags$ git push$ git push --tags$ git push origin <tagname>$ cd path/to/top # 패치하고자 하는 소스 위치 $ patch -p1 < patchfile # 패치 적용
$ cd path/to/top # 패치하고자 하는 소스 위치 $ patch -p0 < patchfile # 패치 적용
$ git config --system ## /etc/gitconfig $ git config --global ## ~/.gitconfig $ git config --local ## repo/.gitconfig
/etc/gitconfig을 찾고, 다음으로 ~/.gitconfig 순서로 찾는다.## 설정 $ git config --global core.eol native ## 설정 확인 $ git config --global --list|grep core.eol
$ git mv oldName newName
변경 사항을 추적하기 어려워지니 절대 삭제후 add 하지 마십시오.-n( --dry-run) 옵션을 사용하면 적용전에 어떻게 변경되는지 테스트가 가능하다.오늘 배운 유용한 git command `fixup`
— Jbee🐝 (@JbeeLjyhanll) January 2, 2022
1. 변경사항 A 커밋!
2. 변경사항 B 커밋!
3. 미처 A에 포함시키지 못한 변경사항 AA 발견!
4. git add AA
4. git commit --fixup=A
$ git push origin HEAD:refs/for/master --no-thin$ git config core.sshCommand 'ssh -o StrictHostKeyChecking=no'