0

I would like to force git to overwrite files in master from a branch, that it does not believe are changed.

Master Branch has file configA Create branch from Master called BranchA which has file configA Create Dev branch from Master called dev. Make changes on dev, including changes to file configA Merge changes from dev to master 

Now I would like to overwrite the changes to configA on Master with file configA on BranchA (original file) It will not merge configA back to the master, because it does not see configA on BranchA as a changed file.

I have used rm --cache to force git to "readd" the file configA to a commit on branchA, but it still ignores it.

Is there any command to force git to merge files from a branch, even if it does not believe they have been changed?

Thanks

1
  • Merge is of changes since a shared base -- and the file configA on the BranchA tip hasn't been changed since the base that tip shares with Master's tip. As Vampire points out, you just want that particular version, and the command you want is git checkout. Commented Oct 15, 2016 at 1:35

1 Answer 1

2

Just get its content and commit it?

git checkout Master git checkout BranchA -- configA git commit -m "whatever" 
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, but it is more than one file. I am not familiar with the "-- filename" after git checkout BranchA. Does that copy the file to the master branch?
@HamletHub: branches don't have files so much as commits have files. What git checkout <commit> -- path does is to extract the file path (or multiple files if that's a directory), into the index/staging-area, and on to the work-tree. Those files are now both in your work-tree and git added to the index/staging-area, where they will be in the next commit you make. Making the commit will move the current branch name to point to the new commit you just made so that they will be in the tip commit on the branch. This is the picky/correct version of "yes, that puts them in the branch" :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.