given the following git log, how do i add a file (which never existed in any commit) to commit B, so that this new file will appear in every other commit that A?
A --> B -----> D ------> F
\--> C --> E --/
In my attempts with git rebase --onto i did not succeed in not having to essentially duplicate every commit amending the contents but i am sure i am not approaching it using the full power of git. Any help?
Note: remote is fine to be forced, or even deleted and pushed again, that's not a worry.
Thanks a lot
The end result will be that : duplicating all the commits.
About the ways to do it, though, you can use git rebase
with some options :
# -i for --interactive
# -r for --rebase-merges
git rebase -i -r A
git
will open a text editor for you, asking you to describe what actions you want to take on each commit.
In that file :
B
pick
to edit
git
will start applying the script you instructed him to, and will pause after reaching B
.
At this point, you can add the extra file :
git add
the file you want git commit --amend
to add it to B
git rebase --continue
to proceed with the rebaseThis should rewrite all the commits after B
.
You can check your local history, and the content of your commits,
if you are satisfied with the result you can push --force
.