在使用git commit时遇到错误:Your branch is up-to-date with 'origin/master',根本原因是没有建立分支或者没有指定分支的问题。可使用以下方法解决。
新建一个分支
$ git branch busbranch
切换分支
$ git checkout busbranch
重新提交你的改动提交到新分支上
$ git add .
$ git commit -m "my test commit"
合并到主仓库中
$ git checkout master
$ git merge busbranch
最后可以push到服务器
$ git push -u origin master
所有的命令整理如下:
eddy@test-ppc MINGW64 /e/gitee/monsys (master)
$ git commit -m "my test commit"
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
modified: README.md
no changes added to commit
eddy@test-ppc MINGW64 /e/gitee/monsys (master)
$ git branch busbranch
eddy@test-ppc MINGW64 /e/gitee/monsys (master)
$ git branch
busbranch
* master
eddy@test-ppc MINGW64 /e/gitee/monsys (master)
$ git checkout busbranch
Switched to branch 'busbranch'
M README.md
eddy@test-ppc MINGW64 /e/gitee/monsys (busbranch)
$ git add .
eddy@test-ppc MINGW64 /e/gitee/monsys (busbranch)
$ git commit -m "my test commit"
[busbranch b6cd93d] my test commit
1 file changed, 1 insertion(+), 1 deletion(-)
eddy@test-ppc MINGW64 /e/gitee/monsys (busbranch)
$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
eddy@test-ppc MINGW64 /e/gitee/monsys (master)
$ git merge busbranch
Updating bab41d0..b6cd93d
Fast-forward
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
eddy@test-ppc MINGW64 /e/gitee/monsys (master)
$ git push -u origin master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 352 bytes | 352.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-5.0]
To https://gitee.com/xxxxx/monsys.git
bab41d0..b6cd93d master -> master
Branch master set up to track remote branch master from origin.
eddy@test-ppc MINGW64 /e/gitee/monsys (master)
原创作品,禁止转载!
相关内容: