git常用的命令

git add 新文件  将工作区域的代码添加到暂存区

git commit -m "first add" 将暂存区文件提交到本地仓库中

git remote add origin git@IP地址:仓库名字,设定远程仓库的名字

git push -u origin master 将仓库文件推送的到远程仓库的主分支中

 

git branch 查看分支

git branch 分支名  创建分支

git checkout 分支名  切换分支

git checkout -b 分支名  创建并且换到分支

git clone git@IP地址:仓库名字/项目名  克隆分支到本地

 

git 如何把分支代码合并到master主分支上

git checkout dev   首先切换到分支

git pull  git@IP地址:仓库名字/项目名   把分支代码pull下来

git checkout master   切换到主分支

git merge dev .把分支的代码merge到主分支

git push 或者 git push -u origin master    (需要输入用户和密码)推上去ok完成,现在 你自己分支的代码就合并到主分支上了

合分支的过程

Administrator@SKY-20190610AAT MINGW64 ~/Desktop/cart (dev)
$ git branch
* dev
  master

Administrator@SKY-20190610AAT MINGW64 ~/Desktop/cart (dev)
$ git pull git@github.com:abang007/cart.git
From github.com:abang007/cart
 * branch            HEAD       -> FETCH_HEAD
Already up to date.

Administrator@SKY-20190610AAT MINGW64 ~/Desktop/cart (dev)
$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.

Administrator@SKY-20190610AAT MINGW64 ~/Desktop/cart (master)
$ ls
Desktop.ini  logs/  mvnw*  mvnw.cmd  pom.xml  src/  start.bat  target/  web/

Administrator@SKY-20190610AAT MINGW64 ~/Desktop/cart (master)
$ git merge dev
Updating 7916097..f4779bd
Fast-forward
 a.txt | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 a.txt

Administrator@SKY-20190610AAT MINGW64 ~/Desktop/cart (master)
$ ls
a.txt        logs/  mvnw.cmd  src/       target/
Desktop.ini  mvnw*  pom.xml   start.bat  web/

Administrator@SKY-20190610AAT MINGW64 ~/Desktop/cart (master)
$ git push -u origin master
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 250 bytes | 250.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
remote:
remote: GitHub found 1 vulnerability on abang007/cart's default branch (1 moderate). To find out more, visit:
remote:      https://github.com/abang007/cart/network/alerts
remote:
To https://github.com/abang007/cart.git
   7916097..f4779bd  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.

Administrator@SKY-20190610AAT MINGW64 ~/Desktop/cart (master)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值