I have the following two branches that differ in files
master
|_ document.txt
|_ document_two.txt
|_ document_three.txt
development
|_ document.txt
|_ document_two.txt
|_ document_three.txt
|_ virus.exe // want to get rid of that
And these are the git log
results of both (from top to bottom)
master
commit: fdsdfsf1342re5252423425242234 (master, development)
add document one
commit: 563523523g233g5232sdfawe22434 (master, development)
add document two
commit: 56652u747241523g52352fsdfawew (master, development)
add document three
development
commit: fdsdfsf1342re5252423425242234 (master, development)
add document one
commit: 563523523g233g5232sdfawe22434 (master, development)
add document two
commit: 1213421g233g5232s41dfawe22434 (development)
ADD VIRUS.EXE ! XXX
commit: 5423345652u7433g52352fsdf1223 (development)
change document three completly
commit: 56652u747241523g52352fsdfawew (master, development)
add document three
Goal
I want to clean up the development branch so it has all the sourcefile states of master and has the virus.exe
file removed.
I already found ways to have the master state overwrite the development file states.
Read here: Make the current Git branch a master branch
But I also want to get rid of files that do not exist within the working set of master. In this example this would be the file virus.exe
. Just creating a new development branch of the master is not an option because it is important to leave the development branch as an orphan. When overwriting/branching the development branch by/off the master branch it will lose the orphan state since it will adapt the whole history of master
Does anybody know a way to:
- get the differences between two branches in files? not their commit diffs
- removing all found differences in files by a final commit (to keep history intact) ?
Edit: I found the command to give me the difference in files:
$ git diff-tree -r --name-status --diff-filter=A master..development
A virus.exe
Is there an elegant way to directly use the output to remove from the development-branch? I would kinda use it in:
git checkout development && git rm virus.exe && git commit -m "clean development" && git push origin