What are .rej files which are created during merge

30,576

.rej files are rejected files (usually hunks patches but not only).

When ever you get those files after merge you will manually have to edit them, fix them and then apply them back.

You can read here some more about it and what is it

.rej file

diff a.txt    (rejected hunks)
....

Fix it manually and then apply the .rej files like a regular patch.

manually merge the change from *.rej into the required file and remove the *.rej file.

Another very usefully article addressing this can be found here.

Share:
30,576

Related videos on Youtube

GajanaN Chalke
Author by

GajanaN Chalke

Updated on May 20, 2021

Comments

  • GajanaN Chalke
    GajanaN Chalke almost 3 years

    I was merging master branch into new branch, there are some .rej files are created.

    I took a pool of master branch into new branch I got conflicts which I've resolved but there are some .rej files.

    Can you please help me to know about the .rej files and what am I suppose to do with those files.

    • Basile Starynkevitch
      Basile Starynkevitch over 8 years
      They are rejection files, describing "failing" merges; you certainly need to look into them.
    • GajanaN Chalke
      GajanaN Chalke over 8 years
      The steps that I've followed are correct or wrong? Actually development was going into Master but for new UI changes new Branch was created mean while some changes has been made into master, so to reflect those changes I took a pool of Master into new branch and I got conflict which I've already resolved but not able to understand about the .rej files. Can you please explain a little bit about failure and cause ?
    • Basile Starynkevitch
      Basile Starynkevitch over 8 years
      Did you look inside some .rej file? Read help.github.com/articles/…
  • GajanaN Chalke
    GajanaN Chalke over 8 years
    I checked the file from both i.e. from master & new branch using beyond compare tool, actually there is no difference not even blank line, in such a case .rej file should not be created, right? Then why .rej file is created? is there any step I missed while merging master into new branch? #I'm using SourceTree for UI.
  • CodeWizard
    CodeWizard over 8 years
    No. .rej files should be created when there is a problem only
  • GajanaN Chalke
    GajanaN Chalke over 8 years
    Thanks a lot @codeWizard, it worked! I merged the branches successfully. Is there any better way(if the way I merged the branches is wrong) to merge the master branch into newly created branch?
  • CodeWizard
    CodeWizard over 8 years
    A better way to merge? depends on several things, how many commits, how many branches, basically - merge often as much as you can to avoid conflicts. you can do a git pull every hour
  • GajanaN Chalke
    GajanaN Chalke over 8 years
    @codWizard Thanks a lot.
  • CodeWizard
    CodeWizard over 8 years
    Np. fell free to read some of my other answers as well and vote for them if you find something new in them.
  • Ben Carp
    Ben Carp over 6 years
    I guess I can simply solve conflicts manually, and then ignore all .rej files?
  • manish ma
    manish ma about 3 years
    @CodeWizard hi, thanks for your answer. I still don't understand how to edit these .rej files. Maybe there was information in the link you provided - but it appears to be broken.
  • haxpor
    haxpor almost 3 years
    Hey thanks for the info! I think it's slightly confusing for the line Fix it manually and then apply the .rej files like a regular patch and manually merge ..... It gives impression that after .rej is created, we have an option to do git apply with that .rej again, or manually do the merge from diff in .rej ourselves. The article you linked in did the latter way though. Anyway, thanks for info! +1