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 +---+---+---
A B C
I fork a repo at point A, then make my own commit B, C,… at the same time, the original repo makes its commit A’. Generally, by applying git rebase, I can make B, C, … based on A’ instead on A.
However, In commit B, I have some files deleted, which remain in A’. Then, every time I excute git rebase, it complains the conflicts on deleted/removed files, which means I need to solve the conflict manually by mergetool or sth else.
I get from the github’s help page that it seems the question is divided to two parts:
-
by git rebase, commits B,C would be canceled and myworkingbranch would go back to A in the cache. During this, how about the files that deleted in B? Will they be restored? I think not because if it will then there would be no problem.
-
if the deleted files is not restored, when I apply commit A’ from upstream/master, which contains changing to the deleted files, there are conflicts. And every time rebasing, the conflicts need to be solved manually. Since there could be hundreds of such files, it is awful.
Qestion: While an upstream/master’s commit that contains changing to the files which is deleted in myworking branchis is applied, is there an elegant way of git rebase, that can Automatically omit the changes refering to those deleted files? in both the two parts of the problem I mentioned above?
I did find that for git merge, I can use .gitattribute file to omit certain files in the upstream branch. Will it work for git rebase? I guess it would not because, if I add those .gitattribute files via a commit, say, D in myworkingbranch, then when git rebase, status A would be in cache, not D, which again contains no .gitattribute files and conflict would occur during patching on A’
Thanks in advance for the help.
You could activate
git rerere, and memorize the conflict resolution once.The subsequent rebase wouldn’t be stopped by the same conflicts.
Yes, a rebase starts by a checkout of the new base (
A'): the files are restored in the index.And then it applies
BandC.