git - git分支和提交混淆
问题描述
我无法将我的提交合并到我在 github 中的主分支。
这是我所做/尝试过的任何事情的一步一步
git push origin master
Everything up-to-date
Anils-MacBook-Pro:React-native-crypto anilbhatia$ git add .
Anils-MacBook-Pro:React-native-crypto anilbhatia$ git commit -m "Final Production working build"
[detached HEAD 46a7f55] Final Production working build
28 files changed, 87 insertions(+), 29 deletions(-)
g rewrite android/app/src/main/res/mipmap-hdpi/ic_launcher.png (97%)
rewrite android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png (98%)
rewrite android/app/src/main/res/mipmap-hdpi/icon.png (99%)
rewrite android/app/src/main/res/mipmap-mdpi/ic_launcher.png (99%)
rewrite android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png (99%)
rewrite android/app/src/main/res/mipmap-mdpi/icon.png (98%)
rewrite android/app/src/main/res/mipmap-xhdpi/ic_launcher.png (99%)
rewrite android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png (98%)
rewrite android/app/src/main/res/mipmap-xhdpi/icon.png (98%)
rewrite android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (98%)
rewrite android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png (98%)
rewrite android/app/src/main/res/mipmap-xxhdpi/icon.png (98%)
rewrite android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png (97%)
rewrite android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png (99%)
rewrite android/app/src/main/res/mipmap-xxxhdpi/icon.png (98%)
delete mode 100644 src/images/123.png
delete mode 100644 src/images/angel.jpg
delete mode 100644 src/images/facebook.png
delete mode 100644 src/images/instagram.png
delete mode 100644 src/images/twitter.jpg
Anils-MacBook-Pro:React-native-crypto anilbhatia$ git push
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use
git push origin HEAD:<name-of-remote-branch>
Anils-MacBook-Pro:React-native-crypto anilbhatia$
Anils-MacBook-Pro:React-native-crypto anilbhatia$ git checkout master
Warning: you are leaving 2 commits behind, not connected to
any of your branches:
46a7f55 Final Production working build
3af30c2 Victory Native graphs work
If you want to keep them by creating a new branch, this may be a good time
to do so with:
git branch <new-branch-name> 46a7f55
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
Anils-MacBook-Pro:React-native-crypto anilbhatia$ git push
Everything up-to-date
Anils-MacBook-Pro:React-native-crypto anilbhatia$ git checkout splashscreen
Branch 'splashscreen' set up to track remote branch 'splashscreen' from 'origin'.
Switched to a new branch 'splashscreen'
Anils-MacBook-Pro:React-native-crypto anilbhatia$ git push
Everything up-to-date
Anils-MacBook-Pro:React-native-crypto anilbhatia$ git status .
On branch splashscreen
Your branch is up to date with 'origin/splashscreen'.
nothing to commit, working tree clean
Anils-MacBook-Pro:React-native-crypto anilbhatia$ git add .
Anils-MacBook-Pro:React-native-crypto anilbhatia$ git commit -m "production build"
On branch splashscreen
Your branch is up to date with 'origin/splashscreen'.
nothing to commit, working tree clean
Anils-MacBook-Pro:React-native-crypto anilbhatia$
现在,我看不到我的最后一个作品,我认为这是因为我做了“git checkout master”和“git checkout splashscreen”。
我可以通过返回这个提交来解决这个问题, 46a7f55 Final Production working build
但是我怎样才能推送到我的 github?
解决方案
只需选择提交 46a7f55 (在任何分支之外,以分离的 HEAD 模式完成)到正确的分支:
git checkout master
git cherry-pick 46a7f55
git push
推荐阅读
- javascript - 异步/等待功能推送不起作用
- laravel - Laravel Webpack“mix.scripts”工作但脚本未在浏览器中加载
- vue.js - 如何处理多参数查询的 Apollo 缓存更新(例如表格数据)
- python - 有效地生成字符串的所有可能子字符串的列表
- ubuntu - 如何获取存储桶中的前 100 个文件
- bash - Keepalived运行bash脚本退出代码问题
- javascript - Javascript生成的输入字段未发布
- python - 如何使用处理时间过长的巨大匹配关键字文件?
- php - 文件夹中随机播放的视频播放列表
- angular - Ionic 4,离子滑动垂直滚动不起作用