git 提交

CREATE
-新建远程仓库,本地创建项目与连接:

  • 仓库创建一个新项目,项目名与本地项目名同名 - 复制仓库新项目的代码地址(HTTPS/ssh)
  • 在项目一级目录下:
  • git init # 当前项目目录生产本地Git管理和.git 目录
  • git add . # 添加所有文件
  • git commit -m “备注”
  • git remote add origin http://yourproject.address.git origin
  • git push -u origin master # 提交

-从A系统迁移到B系统

  • git push --mirror http://yourproject.address.git

BRANCH

  • 创建分支
    git checkout -b feature_x
  • 切回其他分支(master)
    git checkout master
  • 存在分支,提交需指明分支名/追踪
    git push origin feature_x
  • 删除分支–没有pull的情况下feature_x 只对自己可见
    git branch -d feature_x
  • 合并其他分支到当前分支
    git merge feature_x
  • 分支对比
    git diff feature_1 feature_2

TAG & LOG

git log
git tag x.x.x abcdef(提交ID的前10位(建议)字符)


ERRORS

  • remote origin already existes
    解决:删除远程库
    git remote add origin/或删除.git/config中remote两句/直接删除.git文件

  • I don’t handle protocol ‘–https’
    解决:命令重新输入,可能有unicode码之类的。

  • failed to push some refs to ‘https://github.com/QuasimodoZ/xx.git’
    Updates were rejected because the tip of your current branch is behind its remote counterpart. Integrate the remote changes (e.g.‘git pull …’) before pushing again.See the ‘Note about fast-forwards’ in ‘git push --help’ for details.
    原因:最新提交和之前的提交有冲突(常出现于多人协作)
    解决:git pull 并解决冲突

  • git pull 失败:
    原因:远程和本地分支未指定链接,仔细看返回的原因,大部分有提示
    解决:git branch --set-upstream-to=remotes/origin/master(远程分支git branch -a查看远程分支名) master(本地分支)

给已有的commit更改名称
git commit --amend 更改上且仅一次未push的commit名称

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值