How to work around 'git subtree split' failing on revert commits?
I'm running into the problem described in this mailing list post. 'git subtree split' fails to reconstruct the history when a revert commit is followed by a merge commit. I have slightly adjusted the test script provided by Fabien in his mailing list post:
# create a directory that is going to be split
echo "TEST" > doc/README
git add doc
# commit A
git commit -a -m"first version"
# create a branch with a new commit (Z)
git checkout -b test
echo "TEST" > doc/README1
git add doc/README1
git commit -a -m"added README1"
git checkout master
# modify the README file (commit B)
echo "TEST_" > doc/README
git commit -a -m"second version"
# revert the change (commit C)
echo "TEST" > doc/README
git commit -a -m"revert second version"
# or use git revert HEAD^
git subtree split --prefix="doc" --branch=TARGET
# add another commit (to a file *not* in the subtree dir)
echo "BLA" > BLA
git add BLA
git commit -a -m"third version"
# adding another commit to a file in the subtree dir will "fix" things
#echo "MEH" > doc/MEH
#git add doc
#git commit -a -m"fourth version"
# the log will show the 3 commits as expected (including B and C)
GIT_PAGER= git log --oneline TARGET
# merge the test branch
git merge -m"merged test" test
# attempt to re-split; this will fail
git subtree split --prefix="doc" --branch=TARGET
# see what history split generates
git subtree split --prefix="doc" --branch=TARGET2
I have discovered that if the revert commit is followed by another commit that makes changes in the subtree directory, the split will work as expected (see "fourth version" above). This looks like a bug in git-subtree.
However, in my case, the merge has already been performed of course, so I cannot fix things by adding a dummy commit. Is there any other way around this? Perhaps a quick-fix patch to the git-subtree source code?
Suppose we have four commits (with D being the head) A-B-C-D If I want to remove (revert) only the changes in commit B but keep the changes made in C and D, how would you do this? If I do git revert
This question already has answers here: Viewing Unpushed Git Commits How do I list all commits which have not been pushed to the origin yet? Alternatively, how to determine if a commit with particul
I am having trouble with the git revert command. I use Ubuntu 12.04 Linux and Git version 22.214.171.124. I have created a brand new b_test_repo on my local PC, having it tracked from a remote origin b_test
When my SVN server was down I created a Git repository in my SVN repository. After some commits on the master branch I want to rebase the changes back to the SVN server (this is logically possible sin
I have a git project that has one big root directory: C:\MyProject\MyProject C:\MyProject\.git And then all the files and subdirectories are inside C:\MyProject\MyProject. I want to remove that redun
Say I have a git repository that looks like this: A -> B -> C -> D -> HEAD I want the head of the branch to point to A, i.e. I want B, C, D, and HEAD to disappear and I want head to be sy
I used git reset --hard dc082bc... to revert to the branch back to a required previous state, due to some bad commits. This has rewound my local branch fine. However, I want to rewind the branch on
How is git revert used? This might sound like a duplicate question but when people ask it, the response is often, use git reset as per Revert to a commit by SHA hash? Then when someone asks how to use
This question already has an answer here: How to revert a folder to a particular commit by creating a patch 1 answer In git, how to I revert everything in a specific directory to how it was at
This question already has an answer here: How do you revert a faulty git merge commit 2 answers I've stumbled upon this problem with my repo: I have the following structure of my branch tree:
I've just found git-subtree tool that some time ago became a part of main git repo https://github.com/apenwarr/git-subtree/ However I don't fully understand what functionality does this tool provide o
I want to be able to see all of the commits I made today using git log. I came up with git log --after=yesterday However, that seems a little awkward to me, is there a simpler command to achieve the
In my current project I'm using an open source forum ( https://github.com/vanillaforums/Garden ). I was planning on doing something like this : git remote add vanilla_remote https://github.com/vanilla
In some of the repositories that I'm working with, I found git subtree does not behave as expected when sharing repos. Here's the scenario: I own main repo X and push it to origin. My colleague pulls
This is a noob question but I'm under the gun to resolve this. I've inherited an odd problem with a git subtree that appears to be repo corruption. Here's the scenario : a subtree of a git-based proje
I want to revert back to a specific commit ID. Restore a file I git rm-ed. Blow away all commits made since then. And then commit that repo. How would I do this?
How do I revert from my current state to a snapshot made on a certain commit? If I do git log, I get the following output: $ git log commit a867b4af366350be2e7c21b8de9cc6504678a61b` Author: Me <me
I'm trying to add a repo (called cow) to my project using git subtree add. In particular, I'd like to add the branch stable (which is not the master branch). I tried: git subtree add -P cow https://gi
Is it possible to revert only a single file or certain changes in a file in multi file commit? Full story I committed a bunch of files. A number of commits later someone who will remain nameless (JACK
I need a simple solution to update the commits i made in a pull request. I frequently make small corrections on my code and i dont want the git history of that branch to look completely messy for the
In git, how do I work back from a branch head and find every commit that contains (not necessarily touches) a particular file please? The touches version is ok to write: git log mybranch -- filename
Is there a way with git-svn to determine how many commits ahead or behind I am? Thanks!
There has been some question on reverting back to a commit in git but I wanted to make sure. This SO page is one that helps the most: GIT revert to previous commit... how? I have a previous commit, sa
So I have started using git for a while now and understanding how it works gradually. One main point I understood is that - It creates a snapshot every time a new commit is made. Of course snapshot wi
Ok. Simple things should be simple, so I hope it is. :) I have changed a file, now I want to revert back to the latest version in the git repo because my changes are crap and I want to start fresh aga
I want to use subtree merges to pull a remote project into a directory in my own git tree. I followed the instructions here: using subtree merge But I'm not sure how to checkout a tag. I imagine this
I just created a new Heroku app and I don't manage to push the subtree folder backend of my repo (branch staging) to the newly created app myapp-staging (no branch yet). Here is how I push the subtree
I'm using Git and want to get rid of all my current changes and make my files look exactly like they do in my repo on GitHub. How do I do this? I've been searching around and found things but I want t
The git log and git whatchanged shows 2 commits, but both have same lines added, so where was it removed inbetween so it allwed adding same changes again? I tried the below command, how can there be 2
Whenever I split a subdirectory into a branch via git subtree split or (consequently?) when I push a subtree upstream, the commit messages in the new branch/upstream commits have -n and a newline pr
From one of most followed blogs, When you do git fetch, Git gathers any commits from the target branch that do not exist in your current branch and stores them in your local repo. However, it does not
I created a new git repo on our server and then committed all files. Once those files were committed I then created a new .gitignore file and committed it. I did the two commits in the wrong order bec
The problem: I'm getting a merge conflict every time I try to pull into my subtree even when I have no changes. What I'm doing: In subtree-repo # Make some changes $ git commit -am 'Changes made' $ gi
I need to surround git changes between commits with #ifdef macros. This will help me to enable/disable my changes using macros. The idea is to switch quickly between two different source implementatio
I have a bunch of modified files in my git repository and large number of them are xml files. How do I revert changes (reset modifications) of only xml files?
In this def will the subTree function work? I am a bit confused. now a leaf with String s can be considered as a sub tree if a node in the Tree contains String s. data Tree = Leaf String | Node Tr
When reverting multiple commits using git revert -n f0000000 git revert -n baaaaaaa is it possible to ask git to mention in the new commit message all the commits you've reverted, not just one of th
I use Yeoman for deployment of my web app. As per the suggestion of the Yeoman docs, I deploy my site using git subtree, doing something like this: grunt build git add -A dist git commit -m New rele
In git let say I commit A and B A---[B] But then I revert with git revert HEAD So I am there now: [A]---B How do I cancel my revert so that I can go back to B?
I wanted to make two independent changes through branch 1 and branch 2. However, after committing changes through branch 1, I directly used 'git checkout -b branch 2'. thereby including commit from br
This has been sort of asked before, but not exactly. Here is what I want to know. Suppose I have git repository with the following commits: $ git log commit4 commit3 commit2 commit1 I now realize tha
Our remote git repository (on github) is showing '... authored 3 months ago', even though commits were made a few days ago. Someone must have accidentally run a hard reset. Is there any way to find o
I have a folder in my Git repository that I'd like to move out in to its own repository. Is it possible to move the history of that folder along with the folder? I've previously been doing just a git
I am new to GIT and have a question that may be stupid but from so far I searched there is no post mentioning this. Here is the situation: A A' upstream/master-+---+----+----+-----+ | myworkingbranch
I want to be able to get the total number of commits in a github repository between 2 git tags using octokit.net (Github .NET API). Same as what the compare in github does.
So we've gotten a git branch into a tricky state: Two branches: * master * other_branch Last week someone accidentally merged other_branch (prematurely) onto master and pushed to origin. We noticed
Suppose I have the following history: A---B---C----------D------------E master \ /\ / W1--X1--Y1 W2--X2--Y2 topic1 topic2 Is it possible to remove all topic branches and their commits as following A
I have been working in straight line: A---B---C---D---E---F (master:HEAD) Now I want to move backward: git checkout C and move few last commits to a new branch: Option 1: D---E---F (new:HEAD) / A--
I am sure there's a bunch of GIT users out there who's had this problem: Create a branch from master. Let's call it featureX. Somewhere, while working on featureX, you realize you want to make a fixu
I did a mistake that is explained below: I was on the branch feature5 which was around 200 commits forward compared to master, I created a local branch documentation from feature5. (I forgot I wasn't