반응형

특히 git pull 한다고 해서 remote의 내용을 다 가져오는 것이 아니고 특정 branch만 가져오는 것

git pull remote명 branch명을 생략해서 쓰다보니 헷갈리는데 사실은 remote명 local branch명:remote branch명이 생략된 것

remote명은 보통 default인 origin을 쓰므로 origin이 생략된 것이고

branch명은 local에 --set-upstream으로 지정을 해두었으면 그 지정된 branch가 tracking branch로 사용됨, remote와 local의 쌍을 이름을 다르게 하면 매우 헷갈리므로 그렇게는 거의 안쓰므로 보통 local remote동일한 branch명으로 연결해둠

 

tracking branch 지정하기

  • git push --set-upstream origin master = git push -u origin master
  • 한번 tracking branch로 지정해두면 향후 git push/fetch/full 할 때 이후는 생략가능

 

그런 줄 알았는데 git pull 하니까 dev2nd, master둘다 pull함, 특정한 한 브랜치 아니고 tracking branch전부가 대상인듯 

 

반응형
반응형

git shortlog -s -n --all --no-merges

=git shortlog --summary --numbered --all --no-merges

 

--all: 모든 브랜치에 대해, 없으면 특정 브랜치에 대해서만? 

--no-merges:  to exclude statistics from merge commits.

https://stackoverflow.com/questions/9839083/git-number-of-commits-per-author-on-all-branches

반응형
반응형

git log --reverse

반응형
반응형
    • git log --oneline
      • 설명간략히 한줄로만 보여줌
    • git log -5
      • 최근 5개만 보여줌
    • git log --grep=“some message”
      • 커밋 메세지를 검색하여 보여줌
    • git log --decorate --graph
      • 그래프 형태로 보여줌
    • git log --author=dhrim 
      • 특정저자 것만 보여줌
    • git log --before={3.weeks.ago} --after={2010-04-18}
      • 특정시기 것만 보여줌
    • git log --pretty=format:"%h,%ar,%an : %s" 
      • commit 정보를 한줄 단위로 보여주되. format 에 맞게 보여줌
      •  git log --pretty=format:"%h  %ad  %an  %x09  %s" --date=short
        • %h : abbreviated commit Hash(간략) 
        • %an : author name 
        • %ad : author date (format respects --date= option)
        • %ar : author relative date (--date=relative 설정효과, housrs ago, days ago)
        • %as : author short date (--date=short 설정효과)
        • %cd : comitter date (format respects --date= option)
        • %d : ref names
        • %s : subject(commit message)
        • color setting
          • %C(yellow), %C(cyan)
          • %Cblue - 검은바탕에선 잘 안보임, %Cgreen
          • %C(auto) %Creset
    • log format 저장
      • git config --global alias.hs 'git log --pretty="%C(yellow)%h %C(cyan)%as(%ar) %Cgreen%an %C(auto)%d %Creset%s"' -> git hs로 사용가능
      • git config --global alias.hs "log --pretty='%C(yellow)%h %C(cyan)%cd %Cblue%aN%C(auto)%d %Creset%s' --graph --date=relative --date-order"
    • git log --date=...
      • --date=short: yyyy-mm-dd까지만 나옴
      • --date=relative: housrs ago, days ago이렇게 나옴
      • --date=raw: shows the date as seconds since the epoch (1970-01-01 00:00:00 UTC), followed by a space, and then the timezone as an offset from UTC
      • --date=format:%d/%m/%y\ %H:%M:%S
    • git log --graph
      • Git GUI 툴처럼 graph로 보여줌
    • reference
반응형
반응형

git 사용법 알아내기 - git help [알고싶은 명령어]

반응형
반응형

mergeCommit을 revert했더니 에러가 나면서 안됨 (error: commit 247ce0130b0aab7c244e7dcecc7be0fc57083bbe is a merge but no -m option was given.)

-m 옵션을 붙이라는 것 같아서 붙여서 했는데 그래도 안됨.. (error: option `mainline' expects a number greater than zero)

 

왜 에러가 나냐면 어느 부모로 돌아갈지 옵션을 붙여주지 않았기 때문, merge하는 것 자체가 부모가 2개인건데 둘중 어느 부모로 돌아갈지를 지정해줘야함

 

git revert HEAD -m 1 첫번째 부모로 돌아감

git revert HEAD -m 2 두번째 부모로 돌아감

 

첫번째 부모/두번째 부모가 뭔지 알아내는 방법: git cat-file -p [commitHash]

 

 

반응형
반응형
  • commit message로 검색
    • git log --grep='searchKeyword'
    • 만약 검색결과가 많아서 한 화면에 너무 많이 나온다면 --oneline을 붙여서 한줄씩만 보자
      • git log --grep='searchKeyword' --oneline
  • commit번호 (commitHash, commitID)를 알고 있다면
    • git show commitHash

 

반응형
반응형
  • git remote
    • 등록된 remote명 보여줌 
  • git remote -v
    • remote명 + URL
    • -v, -vv, -verbose: 수다스러운 
  • git remote show [remote명]
    •  git remote show origin
    • 이걸로 중요 정보 다 알수 있음
    • remote에 있는 모든 branch 확인가능
      • branch 상태는 tracked, stale(오래된, 상한 이런 뜻) 으로 나눠짐
      • stale한 애는 git remote prune(가지치다 이런 뜻)으로 제거하라고 친절하게 알려주기까지 함
반응형
반응형
  • remote에 아직 안올리고 local내에서만 처리가능할 때
    • git commit --amend로 기존 커밋 수정
    • git reset
    • git checkout
    • 여기서 reset과 checkout의 차이를 알아보자
      • reset 명령은 HEAD가 가리키는 브랜치를 움직이지만(정확히는 브랜치 Refs), checkout 명령은 HEAD 자체를 다른 브랜치로 이동, 참고: https://readystory.tistory.com/150 

 

 

  • remote에 이미 push 했을 때
    • git revert - 특정 커밋만 취소, but 커밋한 기록이랑 그 커밋을 취소한 기록이 모두 남음
    • 기록안남기고 그냥 강제 덮어쓰기 하려면 local에서 reset이나 rebase등으로 원하는 상태로 만든후에 git push ---force, but 협업자가 많으면 멘붕올수 있음
      • 과거의 특정 커밋 수정하기
        • git push --force: 강제로 덮어쓰기
        • git push --force-with-lease: 덮어쓰기 전에 로컬의 remotes/브랜치A가 참조하고 있는 것과 현재 원격의 브랜치A가 참조하고 있는 내용이 동일할 경우에만, 즉, 다른 누군가가 원격의 브랜치A에 push를 하지 않은 상태에서만 git push --force를 실행
        • git push --force함으로 없어져 버린 commit은 어떻게 될까?
          • git show f65ff0737a0a935b67235aae20ec389db32e5240: 일단 git push --force한 당일에는 아래처럼 결과가 나옴
          • change userNo=null error action 5 (added in amazon-echo, naver-clova)
반응형
반응형
  • GIT: author/commiter
    • 차이 
      • author: 특정 commit의 최초 저자
      • committer: 특정 commit에 commit --amend를 해서 여러개 쌓았을 때 마지막으로 쌓은 사람, 혹은 어떤 사람의 커밋을 cherry-pick해서 push했을 때 - author는 어떤사람이고 push한 내가 committer가 됨
    • author/committer로 남겨지는 이름을 변경하고 싶으면 git config로 세팅을 바꾸면 됨. 세팅 안되어 있으면 해당 컴퓨터내 사용자 이름이 자동으로 사용됨, 이렇게 자동으로 이름을 사용할 경우, warning 차원에서 커밋시 다음 메세지를 보여줌
      Your name and email address were configured automatically based
      on your username and hostname. Please check that they are accurate.
      You can suppress this message by setting 
      
          git config --global user.name "Your Name"
          git config --global user.email you@example.com
      
      After doing this, you may fix the identity used for this commit with:
      
          git commit --amend --reset-author
      Your name and email address were configured automatically based
      on your username and hostname. Please check that they are accurate.
      You can suppress this message by setting them explicitly. Run the
      following command and follow the instructions in your editor to edit
      your configuration file:
      
          git config --global --edit
      
      After doing this, you may fix the identity used for this commit with:
      
          git commit --amend --reset-author
  • GERRIT: owner/uploader/reviewer
    • 차이
      • owner: gerrit에서 code review를 생성한 최초 저자
      • uploader: gerrit에서 동일 code review에 여러개가 쌓였을 때 마지막으로 쌓은 사람
      • reviewer: 말그대로 review화면에서 보이도록 설정한 사람
    • gerrit code review에 남는 명칭
    • git config에 설정된 이름이 아니라 git ssh 계정을 따라 정보가 남음
    • hyungsub.song 데스크탑을 받아서 git까지 세팅된 것 그대로 사용하다가 review에 내이름이 아니라 hyungsub.song으로 잘못 남게 되는 것 발견함, 수정하기 위해서는 다음 과정을 거치면 됨
      • git remote -v
        • remote의 상세정보 확인, ssh://hyungsub.song@mod.lge.com:29450/rich-dev/cdp-web이었음
      • git remote remove origin
        • 기존 origin 삭제
      • git remote add origin ssh://sy919.kim@mod.lge.com:29450/rich-dev/cdp-web
        • origin 재등록
      • git remote show origin
        • origin 정상등록 확인, 권한이 없다느니 그런 에러가 남
        • 현재 이 로컬내 키 정보가 hyunsub.song의 계정에만 등록되어 있고 sy919.kim에는 없기 때문
        • 해결을 위해 /home/hyungsub/.ssh/id_rsa.pub내용을 카피해서 gerrit setting화면에 붙여넣자
        • 더 정확히 하기 위해 hyungsub.song계정 gerrit setting에 기존 등록된 id_rsa.pub는 삭제해면 여기로 더이상 남는 것 아예 방지가능함, 하지만 구지 여기까지는...

 

반응형

+ Recent posts