Git Subtree only one file or directory

If I understand, you seem to want to only merge in a certain directory of a different repository, and you want it to be a subtree in your repository. I am going to call the directory of interest in the project.git path_of_interest_in_project and call the destination in your repo directory_desination_path. Try adding the remote project.git … Read more

Why is the `git subtree` not working even though I have git 1.8.3.2 installed on Ubuntu 12.10?

It actually is installed on Ubuntu but for some reason it’s not put anyplace where git can find it. Easiest way is to create a symlink: sudo chmod +x /usr/share/doc/git/contrib/subtree/git-subtree.sh sudo ln -s /usr/share/doc/git/contrib/subtree/git-subtree.sh /usr/lib/git-core/git-subtree UPDATE 1: looks like a patch has been submitted upstream to fix this but it hasn’t yet been merged. UPDATE … Read more

How can I list the git subtrees on the root?

There isn’t any explicit way to do that (at least, for now), the only available commands are listed here (as you noted yourself, but here’s a reference for future seekers): https://github.com/git/git/blob/master/contrib/subtree/git-subtree.txt I went through the code (basically all this mechanism is a big shell script file), all of the tracking is done through commit messages, … Read more

How do I force a subtree push to overwrite remote changes?

The trick was to chain the subtree split into a forced push: git push origin `git subtree split –prefix dist master`:production –force I got this from the Addendum of http://clontz.org/blog/2014/05/08/git-subtree-push-for-deployment/, who actually references this answer on Stack Overflow. I had skimmed this one earlier but Steve Clontz’s post made it click for me.

Add subdirectory of remote repo with git-subtree

I’ve been experimenting with this, and found some partial solutions, though none are quite perfect. For these examples, I’ll consider merging the four files from contrib/completion/ of https://github.com/git/git.git into third_party/git_completion/ of the local repository. 1. git diff | git apply This is probably the best way I’ve found. I only tested one-way merging; I haven’t … Read more

How to rebase after git-subtree add?

This works in simple cases: git rebase –preserve-merges master Thanks to @Techlive Zheng in the comments. You may see fatal: refusing to merge unrelated histories Error redoing merge a95986e… Which means that git failed to automatically apply your subtree. This puts you in the situation @ericpeters described in his answer. Solution: Re-add your subtree (use … Read more

Why can’t I push this up-to-date Git subtree?

I found the answer on this blog comment https://coderwall.com/p/ssxp5q If you come across the “Updates were rejected because the tip of your current branch is behind. Merge the remote changes (e.g. ‘git pull’)” problem when you’re pushing (due to whatever reason, esp screwing about with git history) then you’ll need to nest git commands so … Read more