Request to retrieve, ignore some file changes

When I make a Pull request on GitHub (against the main branch), can we ignore some file changes, for example

  • we have one file named 'fileA' in the 'release' branch, and we have the same file in the 'master', but we are making some changes to 'fileA' in the 'release' branch
  • when we execute the Pull request, is there a way to ignore the changes in fileA file, do not let this merge into "master".
+22
git github pull-request
source share
2 answers

You cannot ignore some files from a stretch request selectively. Two workarounds are possible:

At first -

  • Create a new branch from 'release'
  • Replace unnecessary files from "master"
  • Create a transfer request from this new branch

Second -

  • Create a new branch from 'master'
  • Put changes of necessary files from 'release'
  • Create a transfer request from this new branch

Any of these methods will work. Which will be simpler depends on how many files should be included / excluded.

+14
source share

Create a branch with the last commit you agree with:

git branch my-branch <sha> git checkout my-branch 

Select commits to query as patches :

 git format-patch -10 <sha> --stdout > 0001-last-10-commits.patch 

Apply Patches:

 git am < 0001-last-10-commits.patch 

Your commits will be what they were. You can git push -u origin my-branch immediately.

+2
source share

All Articles