How to remove previously added git subtree and its history

You need to use a filter-branch along with the –prune-empty option to remove any commits that no longer introduce new changes. git filter-branch –index-filter ‘git rm –cached –ignore-unmatch -rf dir1 dir2 dirN file1 file2 fileN’ –prune-empty -f HEAD After that, if you want to recover disk space you will need to delete all the original … Read more

git splitting repository by subfolder and retain all old branches

Short answer git filter-branch offers exactly the functionality you want. With the –subdirectory-filter option you can create a new set of commits where the contents of subDirectory are at the root of the directory. git filter-branch –prune-empty –subdirectory-filter subDirectory — –branches Walkthrough The following is an example to perform this in a safe way. You … Read more

git-subtree pull complications

I had the same problem, and in my case it seems to be due to the initial subtree commit being merge-squashed into the master branch. Looking through the subtree source I found this: https://github.com/git/git/blob/master/contrib/subtree/git-subtree.sh#L224 It looks like subtree greps your git log for git-subtree-dir: foo but doesn’t find a suitable commit. Try git log –grep=”git-subtree-dir: … Read more

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)