Git new branch is not a branch when using a previous commit

I was on a branch in Git, doing some work. Then I decided to check out one of my previous commits on that branch using the commit’s hash, with git checkout -b new_branch 6e559cb. Now when I enter “git branch” it says that I’m currently on “(no branch)”. How do I merge this no-branch into the branch it was split from? Thanks!

  • Update a local branch with the changes from a tracked remote branch
  • Separating a feature into a new branch in Git
  • Listing and deleting Git commits that are under no branch (dangling?)
  • Git: merge only the changes made on the branch
  • Creating a branch with TortoiseSVN without /trunk structure
  • GIT: What is commits priority during merge?
  • Git how to removed selected commit from tree?
  • How to push local Git repo to newly created Google Code project?
  • What does “Changes not staged for commit” mean
  • Dumping binaries in Git and reverting?
  • Have remote git repository refuse merge commits on push
  • gitkraken doesn't automatically delete remote feature branches
  • 2 Solutions collect form web for “Git new branch is not a branch when using a previous commit”

    If somehow your command didn’t create a branch at 6e559cb, you simply can create one now (where you are currently in “no branch”, that is “detached HEAD” mode.

    git branch new_branch
    git checkout new_branch
    # or git checkout -b new_branch
    

    I am not sure that you did it in proper way (I am assuming that you are working on “new_branch” and you wanted to apply commit from another branch on top of that).

    The most convenient way would be do cherry-pick (or merge) commit from one branch to another.

    git[new_branch]$ git cherry-pick 6e559cb
    
    Git Baby is a git and github fan, let's start git clone.