Git Merge subdirectory to branch to root directory of master

I have a branch that has the content of the master branch as a subdirectory. Now I made some changes to this subdirectory. Ideally I want to be able to merge these changes back into the master branch.

Branch layout:

  • Issue cloning GitHub private repo onto remote server
  • How can I merge two git commits
  • Problems adding git remote repository
  • Error when pulling and pushing to github
  • How to extract different file versions between two tags in Git?
  • Can I issue git rev-parse on remote repository without a local copy?
  • index.html
      > a.txt
      > b.txt

    Master layout


    How would I go about doing this? Is it even a good approach? In SVN I avoided merging subdirectories back into the trunk. But this is a somewhat different use case, the layout of both, the branch and master, will never change.

  • Is there a way to add a hidden folder (with . prefix) to SourceTree?
  • Git Push: What is the difference between HEAD:refs/heads/<branch> and <branch>?
  • Connecting to a TFS server closes a Git solution
  • git merge conflict due to renaming in two branches - how to fix & avoid in future?
  • Find commit by hash SHA in Git
  • Can you share a file and it's history between two git repositories?
  • 2 Solutions collect form web for “Git Merge subdirectory to branch to root directory of master”

    You could try

    • making a branch from your current branch (git branch to_be_merge_to_master)
    • moving back your file to the correct structure (git mv ...)
    • merging that second branch to master

    make use of git submodules

    Git Baby is a git and github fan, let's start git clone.