Git常用命令

新建分支
git branch newbranch

查看分支
git branch

切换分支
git checkout newbranch

查看是否切换到该分支
git branch

提交改动到当前分支
git add.
git commit -a

查看提交状态
git status


切换回主分支
git checkout master

将新分支提交的改动合并到主分支上
git merge newbranch

查看合并后产生的冲突
git diff

再次提交

删除分支
git branch -D newbranch


git add.
git comm -m "提交信息"
代码上传至远程库中
git pull origin master
git push origin master


$ git push origin master
To https://gitee.com/l_jj/bookms.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/l_jj/bookms.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.


git pull --rebase origin master

git push -u origin master

和远程仓库建立连接
git remote add origin 远程仓库地址


从远程仓库克隆
git clone 远程仓库地址 本地目录

git仓库初始化
git init


git pull 版本库更新
git add  新增文件加入Git中
git rm   删除
git commit   提交当前工作空间的内容
git push   将本地commit的代码更新到远程版本库中
git log  查看历史日志
git revert 还原某一个版本的修改
git rebase 分支内节点的移动(第一次提交完成时,分支点在a,第二季提交完成时,分支点在b,具有从a->b的能力)
git reset  将当前工作目录完全回滚到制定的版本号

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值