You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Creating branch from detached HEAD branches from master #6085
While in a detached HEAD state, creating a new branch results in that branch being branched from master instead of the currently checked out commit.
Version
GitHub Desktop:
1.4.3
Operating system:
Windows
Steps to Reproduce
From terminal: git checkout <some_commit_hash>
In GitHub Desktop: Branch -> New branch...
Type a name.
Create branch.
Expected Behavior
The newly created branch should point to <some_commit_hash>, as the dialog states You do not currently have any branch checked out (your HEAD reference is detached). As such your new branch will be based on your currently checked out commit (<some_commit_hash>).
Actual Behavior
The newly created branch points to the HEAD of master.
Additional Information
This happens on 1.4.2-linux1 from @shiftkey's fork as well.
createBranch uses this startPoint state to revert to using the default branch name
letstartPoint=undefinedif(this.state.startPoint===StartPoint.DefaultBranch){// This really shouldn't happen, we take all kinds of precautions// to make sure the startPoint state is valid given the current props.if(!this.props.defaultBranch){this.setState({currentError: newError('Could not determine the default branch'),})return}startPoint=this.props.defaultBranch.name}
There's no tests around getStartPoint so I want to wrap this current behaviour in tests before I fix the underlying issue.
I was just about to post this exact same bug report but did one last search before submitting and found it already reported. It looks like it's already been reproduced, but I'll go ahead and include the details I had filled out anyway (as the system and GH Desktop versions are different):
Description
Creating a new branch from a commit that is detached from HEAD works incorrectly. The dialog box says that it will create the branch from the current commit, but when I publish the branch to GitHub, it is clear that the branch is actually created from the default branch by looking at the commit history.
Version
GitHub Desktop: Version 1.5.0 (MacOS)
Operating system: Mac OS Mojave Version 10.14
Steps to Reproduce
Checkout a particular commit to where you will be detached from HEAD (easiest to do with a SHA on the command line e.g. git checkout abcdef12)
Notice that GitHub desktop relays the current git status with the SHA and the message "Detached HEAD"
Select "New Branch" from the branch dropdown list and notice that the dialog says that the new branch will be created from the "currently checked out commit" and that it again displays the current SHA
Without making any changes, publish the branch to GitHub
Go to GitHub and select that branch from the list of branches
Notice that the history reflects the history not of the checked out commit, but of the default branch
Expected Behavior
I expect that the created branch would be created from the checked out commit, rather than the default branch (like it says it will in the GH Desktop dialog box).
Actual Behavior
The newly-created branch is actually created as a branch from the default branch.
Additional Information
I can accomplish this from the command line with the following steps:
Checkout a particular commit to where you will be detached from HEAD (easiest to do with a SHA on the command line e.g. git checkout abcdef12)
Instead of creating a new branch from GH Desktop, create it from the command line git checkout -b new-branch
Go to GH Desktop and notice that it sees you're on the new-branch
Publish the branch
Go to GitHub and note the branch history - this matches the history of the checked out commit, rather than the history of develop
Logs
There are no logs saved to the location mentioned in the contributing guide ~/Library/Application Support/GitHub Desktop/logs/. If someone can point me to the location I'd be happy to provide them.
Activity
shiftkey commentedon Nov 5, 2018
@jeffdgr8 thanks for the report! I've been able to reproduce this on
masterand I think it comes down to two things:getStartPointseems to default to using the default branch (ignoring the fact we're in adetached HEADstate)createBranchuses thisstartPointstate to revert to using the default branch nameThere's no tests around
getStartPointso I want to wrap this current behaviour in tests before I fix the underlying issue.mm-gmbd commentedon Nov 20, 2018
I was just about to post this exact same bug report but did one last search before submitting and found it already reported. It looks like it's already been reproduced, but I'll go ahead and include the details I had filled out anyway (as the system and GH Desktop versions are different):
Description
Creating a new branch from a commit that is detached from HEAD works incorrectly. The dialog box says that it will create the branch from the current commit, but when I publish the branch to GitHub, it is clear that the branch is actually created from the default branch by looking at the commit history.
Version
Steps to Reproduce
git checkout abcdef12)Expected Behavior
I expect that the created branch would be created from the checked out commit, rather than the default branch (like it says it will in the GH Desktop dialog box).
Actual Behavior
The newly-created branch is actually created as a branch from the default branch.
Additional Information
I can accomplish this from the command line with the following steps:
git checkout abcdef12)git checkout -b new-branchnew-branchLogs
There are no logs saved to the location mentioned in the contributing guide
~/Library/Application Support/GitHub Desktop/logs/. If someone can point me to the location I'd be happy to provide them.shiftkey commentedon Nov 20, 2018
@mm-gmbd thanks for the extra details - please follow along with #6104 which should resolve this
bangke213 commentedon Nov 23, 2018