![]() Git checkout origin/branch-with-the-changes. # Get the version of the files from the other branch # Create an orphan branch with no history but your files Note that this approach will not delete files or give you the history, but it will give you the conflicts between each file. ![]() If you have all the commits all over the place then you likely won't need to keep the history, here's one approach that works for those cases. Case 2: Clean commits are not important, but knowing the conflicts is You might want to git rebase -i HEAD~N where N is some number of commits to add them as pick COMMIT_HASH lines in the history if you need to. Use git cherry-pick COMMIT_HASH for those cases. If your team does clean commits, then digging around in the history for the commits could be fruitful. This gets you the folder as it is on the other branch as unstaged changes. Git checkout origin/branch-with-the-code-you-want. Git read-tree -prefix=cassandra/ -u infochimps/master:cookbooks/cassandraīut off course, verify manually that this does what you want. It's bizarre, - but the read-tree step can possibly fail like this:Įrror: Entry 'infochimps/cookbooks/cassandra/README' overlaps with 'cookbooks/cassandra/README'. Note that the target subdirectory name should also be cookbooks/cassandra, or you would see: fatal: Not a valid object nameĬommit the change git commit -m 'merging in infochimps cassandra' ![]() cookbooks/cassandra, on the upstream branch of the source repository. This reads the tree for only the required source subdirectory i.e. Merge only infochimps/cookbooks/cassandra into cassandra git read-tree -prefix=cassandra/ -u infochimps/master:cookbooks/cassandra This records the fact that infochimps/master has been merged, without actually modifying any file in the target branch) Basic Branching First, let’s say you’re working on your project and have a couple of commits already. Switch back to your original story and continue working. After it’s tested, merge the hotfix branch, and push to production. (this performs a merge by using the 'ours' strategy ( -s ours), which discards changes from the source branch. You’ll do the following: Switch to your production branch. Perform the merge git merge -allow-unrelated-histories -s ours -no-commit infochimps/master Here are the commands I used to merge themĪdd the repository and fetch it git remote add -f infochimps git:///infochimps cluster_chef.git Remote repository source I want merged into cookbooks/cassandra => infochimps/cookbooks/cassandra My repository target directory => cookbooks/cassandra Just as an alternative to the SO question " How do you merge selective files with git-merge?", I just found this GitHub thread which could be more adapted for merging a whole subdirectory, based on git read-tree:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |