'Git is not calculating files properly

We have following branch structure

  1. Feature branches - one for each user story
  2. Environment branches (QA, UAT and master)

Deployment process Once user story is completed we merge feature branch into QA branch where testing is done. We keep doing this until we have enough stories to be promoted to UAT branch. We merge only stories to UAT branch that we get sign off from client/QA team. Similarly for master branch.

After each deployment, we rebase all the feature branches (under development) from master. When we are trying to merge updated feature branch into QA branch we are seeing so many files in pull request. The files that are already present in QA (merged during QA deployment phase) are shown as new files while updated file are also showing same changes.

What could be the reason here? How can I make sure git calculates files properly while creating pull request.



Solution 1:[1]

for each feature branch, you need to do a rebase --onto qa (the target branch of your PR) with two parameters:

  • the parent of the first commit of that feature branch
  • the feature branch name "F"

That is:

git rebase --onto qa FirstCommit~1 F

If you know from which branch "B" the F branch started, use git merge-base:

git rebase --onto qa $(git merge-base B F)~1 F

If not, do a git log F to visually check which commit is the first for the feature branch F.

Try it for one feature branch, git push --force that branch once rebased on top of the target branch, and check the PR which was in progress (with too many commits) now display only the commits from F.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1