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会教你怎么做!

posted @ 2020-12-24 08:50  超级爱度假  阅读(610)  评论(0)    收藏  举报