Git - 个人出现的git错误整理

1.提示有:

fatal: Not a valid object name: 'master'.

这是因为本地的‘master’分支还并未创建,需要在‘commit’后才会自动创建 。这时:

git add .    //将所有的文件加到暂存区
git commit -m 'after commmit, the local master branch init'    //将暂存区的文件提交到本地git仓库,并写明此次提交信息

上面两条命令执行完后会在本地git仓库创建master分支。

使用命令查看所有分支,其中带 * 表示当前所在分支:

git branch -a


2.提示有:

No tracked branch configured for branch master. To make your branch track a remote branch call, for example, git branch --set-upstream-to origin/master master

或者:

There is no tracking information for the current branch.

No tracked branch configured 。是说没有配置一个本地git仓库跟踪到远程git仓库,此时:

进入在bash命令行进入Git项目仓库:

git branch --set-upstream-to origin/master① master②

①指的是远程分支,其中origin/远程具体分支,②指的是本地分支



3.提示有:说明远程分支master不存在

error: the requested upstream branch 'origin/master' does not exist

附带提示:

hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run "git fetch" to retrieve it.
hint:
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: "git push -u" to set the upstream config as you push.

这里有两种情况:

1.若远程Git仓库已有①分支,很显然这里没有,所有是第二种情况,执行命令

git fetch
2.若远程Git仓库没有①分支,执行命令
git push -u


4.提示有:说明本地的仓库的master分支没有与远程仓库的一个分支关联

fatal: The current branch master has no upstream branch.

执行命令:

git push --set-upstream origin master

来将远程的master分支与本地的master分支关联


其中出现2,3,4提示bash会教你怎么做!

  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值