OKdevTV Docs
Home OKdevTV
ESC
git 2 min read 2.5 KB Raw Markdown
On this page (9)

Git Status

branch diverged

text
On branch main
Your branch and 'origin/main' have diverged,
and have 2 and 7 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)
  • Status branch diverged

  • Solve

text
# folder backup
# git local commit
# git pull remote
# merge conflict
# git local commit
# git push

gitk
git status
git pull origin main
git commit -m "tmp"
git commit -am "tmp"
git pull origin main
git add .
git status
git commit -m "tmp2"
git pull origin main
atom .
git status
git add .
git commit -m "tmp3"
git status
git push origin main
gitk
  • 결과
branch merged

파일 하나 롤백

text
git checkout b1fea8b -- server.js

Commit 롤백

text
git revert HEAD
git revert hashhash

파일 하나 unstage

text
git checkout -- server.js

git diff

  • 이전 파일과 비교
text
git diff HEAD^ HEAD
  • 브랜치 파일 비교
text
git diff develop main path/to/file
  • As of Git 1.8.5, @ is an alias for HEAD, so you can use:
text
git diff @~..@
  • The following will also work:
text
git show
  • If you want to know the diff between head and any commit you can use:
text
git diff commit_id HEAD
  • And this will launch your visual diff tool (if configured):
text
git difftool HEAD^ HEAD

git log

  • 최근 2일간 계정에 대한 변경 이력
text
git log --pretty=format:"%h - %an, %ar : %s" --author kenu.heo --since=2.days
  • commit별 변경 파일 목록
text
git log --name-only -1 f002a898

로컬 브랜치 정리

text
git remote prune origin
git fetch -p

errors

  • The remote end hung up unexpectedly
text
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
  • Solve
text
git config http.postBuffer 724288000

or

text
git config --global core.compression 0
git clone --depth 1 https://github.com/kenu/okdevtv
cd okdevtv
git fetch --unshallow
git pull --all

git pull push timeout

text
# ~/.ssh/config
Host github.com
    Hostname ssh.github.com
    Port 443