代码改变世界

git常用命令

2023-05-15 17:07  john_zhu_t  阅读(54)  评论(0)    收藏  举报
  1. View author names with commit count.
    $ git shortlog -nse

  2. To get the particular user’s commit Git log, run the “git log” command with the “–author” parameter and its value:
    $ git log --author=zhuliangshun

  3. git log command option: -p, -u, --patch #Generate patch (see section on generating patches)
    --name-only #Show only names of changed files.

  4. see the difference for a file "main.c" between now and two commits back, here are three equivalent commands
    $ git diff HEAD^^ HEAD main.c
    $ git diff HEAD^^..HEAD -- main.c
    $ git diff HEAD~2 HEAD -- main
    git diff e16acac~ e16acac

  5. Retrieve a git repository for a .git file
    $ git checkout .

  6. git a archive
    $git archive --remote=ssh://x.x.x.x:xxxx/xxx.git branch dir1/dir2/xx/remote_file | tar -xO > local_file
    Note: -xO means extract to standout