Git 进阶

一、进阶命令

1.git fetch

到远程仓库中拉取所有本地仓库中还没有的数据,但只是拉取,不自动进行分支合并,需要手工进行,区别于git pull。

  • 用法:git fetch [远程仓库名]

2.git remote show

查看远程仓库的信息

  • 用法:git remote show [远程仓库名]
$ git remote show origin
* remote origin
  URL: [email protected]:name/github.git
  //在issues和master分支上执行 git pull 对应的远端分支
  Remote branch merged with 'git pull' while on branch issues
    issues
  Remote branch merged with 'git pull' while on branch master
    master
  //远端还没fetch到本地的新分支
  New remote branches (next fetch will store in remotes/origin)
    caching
  //本地还有,远端以及被删除的分支
  Stale tracking branches (use 'git remote prune')
    libwalker
    walker2
  Tracked remote branches
    acl
    apiv2
    dashboard2
    issues
    master
    postgres
  //本地执行push对应关联的的分支
  Local branch pushed with 'git push'
    master:master

3. 只拉取感兴趣的commit之,git cherry-pick

  • git cherry-pick commit1

4. 去除很久之前的某次提交,git revert

  • git revert commit_id
  • 效果不是直接将这个记录给删除了,而是重新提交一个commit,将之前的提交给恢复了
  • 如果有多个commit需要revert的话,需要按照从后向前的顺序进行revert

你可能感兴趣的:(Git 进阶)