git常用操作

1.clone(克隆)

git gui:

git gui首页选克隆已有版本库,填写

Source Location: http://192.168.10.xx/xxx.git

Target Directory:  e:/git/mine

git bash:

git clone http://192.168.10.xx/mine.git

2.fetch(同步获取,不合并)

git gui:

远端->fetch->origin:跟新远端服务器上的分支到本地。本地也维系了服务器上的所有分支,fetch就是让这些分支与服务器上的同步。

git bash:

git fetch 

3.branch(显示分支)

git gui:

repository->显示所有分支的历史。

git bash:

git branch -r          显示远端分支

git branch -a          显示所有分支

4.checkout(切换分支)

git gui:

branch->checkout

git bash:

git checkout reflection        切换到reflection分支

5.pull(获取分支,合并)

git gui:

merge->本地合并

git bash:

git pull      获取远端分支,并合并

6.push(上传分支,合并)

git gui:

先缓存改动,然后提交(将缓存的改动提交到本地分支上),再上传(提交到服务器分支上)

git bash:

git push origin test:master         // 提交本地test分支作为远程的master分支

git push origin/master      //用本地的master分支提交更新到服务器上的该分支

原文地址:https://www.cnblogs.com/DjangoBlog/p/3510774.html