简体   繁体   English

git分支和提交混乱

[英]git branching and commit confusion

I am unable to merge my commit to my master branch in github. 我无法将我的提交合并到github中的master分支中。

This is step by step of whatever I have done/tried 这是我所做/尝试过的所有步骤

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$ 

Now, I am unable to see my last work, which I think is because I did "git checkout master" and "git checkout splashscreen". 现在,我看不到我的上一份工作,我认为这是因为我做了“ git checkout master”和“ git checkout splashscreen”。

I can fix that by going back to this commit 46a7f55 Final Production working build but then how can I push to my github? 我可以通过返回到commit 46a7f55 Final Production working build来解决此问题,但是如何将其推送到github?

Simply cherry-pick that commit 46a7f55 (done outside of any branch, in a detached HEAD mode) to the right branch: 简单地摘樱桃犯下46a7f55(任何分支之外完成的,在一个分离的头模式),以正确的分支:

git checkout master
git cherry-pick  46a7f55 
git push
  To verify the current branch and status. Just do git status Looks like you are not in branch 

"You are not currently on a branch". “您当前不在分支机构中”。

    git checkout splashscreen

     if you want to merge master changes to splash screen just do
     git merge master.

if you want splash screen changes to master, checkout to master git checkout master git merge splashscreen. 如果您希望将初始屏幕更改为master,请结帐至master git checkout master git merge初始屏幕。

  or else if you know the commit id, you could do
  git cherry-pick <commid-ID>
  git push

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM