Git-命令集合

2019-04-23  本文已影响0人  yuyangkk

先来一张图网上的图镇楼


git 命令.jpg

1. 删除远程已经存在的文件

删除缓存

git rm -r --cache somepath/文件名
eg. git rm -r --cache .DS_Store

commit

git commit -a "删除并停止追踪.DS_Store"

提交到远程

git push develop origin/develop

2. 分支重命名

同事A操作

  1. 重命名分支
KayedeMacBook-Pro:gittest kaye$ git branch -m oldbranch newbranch
KayedeMacBook-Pro:gittest kaye$ git branch 
  develop
  master
* newbranch
  1. 删除远程分支
KayedeMacBook-Pro:gittest kaye$ git push origin -d oldbranch
To https://github.com/yuyangkk/gittest.git
 - [deleted]         oldbranch
  1. 推送到远程并绑定
KayedeMacBook-Pro:gittest kaye$ git push --set-upstream origin newbranch
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 268 bytes | 268.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: 
remote: Create a pull request for 'newbranch' on GitHub by visiting:
remote:      https://github.com/yuyangkk/gittest/pull/new/newbranch
remote: 
To https://github.com/yuyangkk/gittest.git
 * [new branch]      newbranch -> newbranch
Branch 'newbranch' set up to track remote branch 'newbranch' from 'origin'.

同事B、C、D... 操作

  1. 查看远程变动
KayedeMacBook-Pro:gittest kaye$ git remote show origin
* remote origin
  Fetch URL: https://github.com/yuyangkk/gittest.git
  Push  URL: https://github.com/yuyangkk/gittest.git
  HEAD branch: master
  Remote branches:
    develop                       tracked
    master                        tracked
    newbranch                     tracked
    refs/remotes/origin/oldbranch stale (use 'git remote prune' to remove)
  Local branches configured for 'git pull':
    develop   merges with remote develop
    master    merges with remote master
    oldbranch merges with remote oldbranch
  Local refs configured for 'git push':
    develop pushes to develop (up to date)
    master  pushes to master  (up to date)
  1. 同步
KayedeMacBook-Pro:gittest kaye$ git remote prune origin
Pruning origin
URL: https://github.com/yuyangkk/gittest.git
 * [pruned] origin/oldbranch
KayedeMacBook-Pro:gittest kaye$ git branch -a
  develop
  master
* oldbranch
  remotes/origin/develop
  remotes/origin/master
  remotes/origin/newbranch
  1. 重命名
git branch -m oldbranch newbranch
  1. 绑定
git branch --set-upstream-to=origin/newbranch newbranch
上一篇 下一篇

猜你喜欢

热点阅读