Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 在推送空合并提交后还原它_Git_Github_Git Merge - Fatal编程技术网

Git 在推送空合并提交后还原它

Git 在推送空合并提交后还原它,git,github,git-merge,Git,Github,Git Merge,我采取的步骤: 将主分支合并到我的要素分支中 开始解析提交,在其中一个冲突上意外地使用了他们的“解析”,并希望重做 重置所有更改 此时,我似乎什么也做不了,因为我处于合并状态,我意外地提交了这些更改并将其推送到GitHub(我使用了SourceTree并勾选了选项!) 现在,每当我尝试从master合并时,它都假定我已经有了最新的更改,并且没有向我的功能分支添加任何内容 我试着运行git revert-m 1,但我得到了: On branch feature/profile_page Your

我采取的步骤:

  • 将主分支合并到我的要素分支中
  • 开始解析提交,在其中一个冲突上意外地使用了他们的“解析”,并希望重做
  • 重置所有更改
  • 此时,我似乎什么也做不了,因为我处于合并状态,我意外地提交了这些更改并将其推送到GitHub(我使用了SourceTree并勾选了选项!)
  • 现在,每当我尝试从master合并时,它都假定我已经有了最新的更改,并且没有向我的功能分支添加任何内容

    我试着运行
    git revert-m 1
    ,但我得到了:

    On branch feature/profile_page
    Your branch is up-to-date with 'origin/feature/profile_page'.
    nothing to commit, working tree clean
    
    然后我尝试在更改之前恢复它,但现在本地是GitHub上功能分支后面的一个提交

    有什么想法吗

    这是我的日志:

    * ff46aa6 (HEAD -> feature/profile_page, origin/feature/profile_page) Revert     "Added link to user profile page in MainMenu"
    *   64e96b3 .
    |\  
    | * 9c023f5 (origin/master, origin/HEAD, master) Made the delete button invoke a pop-up which can delete the responders.
    | * 87a028c Added a placeholder page that can be used to link to, or navigate from when you need a placeholder page.
    | * 6ae954d Added the ResponderGroupPage and new delete icon.
    | * 752fb83 Updated the layout to closer match the mock-up
    | * 55e8c29 Added missing schedule icon
    | * 6255338 Tweaks to make the page work/look correct on iOS
    | * 178beb1 Update to the IncidentHistoryPage so that it displays a history of an event as a list under your selected item when you select one.
    | * 5bfbbf1 Added titles to pages and button to link to IncidentHistoryPage.
    | * 4570346 Added basic IncidentHistoryPage using mock data
    * | 663a378 Added link to user profile page in MainMenu
    * | 123da81 Added EditProfilePasswordPage and CloseAccountPage
    * | 40a00ea Added change phone number page
    * | b80f9af Added Change email page
    * | 8a3710a Added MySubscriptions Page
    * | 3c8ddee Added MyAccountPage
    * | dd4fa9e ImageWithPopupMenu handles events
    * | cbfae5f Added ImageWithPopupMenu
    * | 304dd5c .
    * | b730e7f EditProfilePage first pass
    * | 0ac9603 Added UserProfile view model
    * | af7f6ed .
    * | 5f4e0c0 Profile Page first pass
    | | * bbbbc4d (origin/feature/api_hooks) Setting up a wearer after activating a device will now associate the wearer with the device. Added WearerDataStore which will retrieve and manage the wearer list shown on the home screen.
    | | * 45b3639 App will now check if a user is currently logged in when it launches.     - If there is currently an active session, which is not authenticated with the API key, then the app will navigate to the home screen instead of landing.
    | | * 88250f5 Sign in page now using Bindings with view model for the entry text. Sign in page now using localisation. Added api calls to sign up process. Added validation to the sign up process for checking email address and phone numbers.
    | |/  
    | *   2590342 Merge branch 'master' of https://github.com/FirstAppLtd    /Watchie_Xamarin
    | |\  
    | | * 4e13537 Added the EditSafezonePage and placeholder pop-ups for CALL/RAISE SOS on the Homescreen and Wearer Profile screens.
    | | *   ee1a2dc Merge branch 'master' into hockeyapp_integration
    | | |\  
    | | | * 7f1d961 New icon paths
    | | * |   3d05a1f Merge branch 'master' into hockeyapp_integration
    | | |\ \  
    | | | |/  
    | | | *   66d6303 Reworked the Homescreen so that it works on iOS as the list view didn’t work correctly. I moved the Icons on iOS into the root resources so that they can be indexed in the same way as on Android to avoid any needing to do #ifIOS look here.
    | | | |\  
    | | | | * d7e2d63 (origin/UpdatingIcons) Fix for the Homescreen so that it displays correctly on iOS. Moved where the iOS icons are stored so that they can be referenced exactly like the Android assets.
    | | | | * 5d6846a New branch updating the icons
    | | * | | a8d3ddc Set Android HockeyAppId
    | | * | | df479a2 Set iOS HockeyAppId
    | | * | | d0c820d Integrated HockeyAppId from info.plist. Disabled AuthenticateInstallation call for current config.
    | | * | | d0702fe Added iOS HockeyApp to the Info.plist file
    | | * | | 05f627a Refactored the HockeySDK App ID to the AssemblyInfo file for Android
    | | * | | f99cf8e Added HockeySDK update to Android
    | | * | | d0c94d0 Added ability to enable HockeySDK User metrics in Android
    | | * | | 2b14729 Disabled HockeySDK for iOS
    | | * | | 32fa935 Integrated HockeySDK for Android to detect crashes
    | | * | | 58017a5 Added HockeySDK NuGet package to Android solution
    

    您在合并之前还原了提交,这将创建一个新的提交并撤消该提交。我认为您想要做的是
    git reset
    ,它将分支引用重置为提交

    如果要在合并任何操作之前重置为,请执行以下操作:

    git签出功能/配置文件\u页面
    git reset--hard 663a378
    ,它将在合并提交之前将功能分支本地设置为提交。在remote中,您将不得不执行一个git push-f,这将重写remote中的历史记录。如果只有您一人在分支上工作,并且您拥有正确的权限,那么就可以了


    或者您可以在663a378
    git checkout-b 663a378
    上创建一个新的功能分支,您可以使用它来执行您想要的合并。

    根据您的日志,我认为最干净的解决方案是:

    git checkout 663a3784ab82f019996a5091f3dfb2401c0403b5 -b feature_clean
    
    这将在标记为“有效”(编辑前)的合并之前,将提交签出为新分支“功能\清除”。然后可以执行合并(
    git merge master
    )并确保它是干净的。最终,您可以用特征替换特征,例如删除前者并重命名后者:

    git branch -d feature # delete old branch
    git branch -m feature_clean feature # rename clean branch
    git push -f # force push feature to rewrite history on remote
    
    我不建议
    git reset 663a37的原因是--硬
    之后是强制推送,这样您可以保留“断开”的分支,并可以根据需要执行
    git checkout 663…
    以解决冲突


    我希望这会有所帮助。

    这里有一种重播提交的方法:

  • 使用“正在进行的工作”分支从提交重新启动
    663a378

  • 重新运行“将主机合并到此分支”:

  • 解决冲突,
    和提交,可能编辑提交,将您期望的分支名称放入消息中(例如:
    “将主机合并到功能/配置文件页面”
    ,而不是
    “将主机合并到wip”

  • 如果您对此新合并感到满意:将以前的分支移动到这些新提交:

    # push current commit to the remote "feature/profile_page" branch :
    git push -f origin wip:profile_page
    
    # set your local "profile_page" branch to this new commit :
    git branch -f profile_page wip
    
    # switch to other branch and delete wip :
    git checkout profile_page
    git branch -d wip
    

  • 你能添加你的git日志吗?我还想知道为什么要将master合并到功能分支中,这似乎有点奇怪?将master合并到功能中以确保在提交给master之前一切正常,将附加日志请使用
    git log--decoration--all--oneline--graph
    或类似方法完成!合并提交是
    64e96b3
    以句号作为消息的提交,谢谢!这似乎是最干净的解决办法;由于我的功能分支在我向master承诺之后结束了,我不需要保留它,所以它最有意义。很高兴我能提供帮助!
    git merge master
    
    # push current commit to the remote "feature/profile_page" branch :
    git push -f origin wip:profile_page
    
    # set your local "profile_page" branch to this new commit :
    git branch -f profile_page wip
    
    # switch to other branch and delete wip :
    git checkout profile_page
    git branch -d wip