Git merge different file names

Here’s my scenario:

I’m working on fixing bugs in file1 in a local branch. My coworker is in his own local branch, merging file1 into file2 in a refactor. He finishes his work and merges back into master and pushes. Now file1 no longer exists in the HEAD.

  • Is there an “impact graph” tool for non-GitHub projects?
  • Using Liquid tags in a Jekyll page not working
  • Android Studio and Git - How do I GPG-sign my commits?
  • GitHub - List commits by author
  • What happens if i push a nontracking branch?
  • View uncommitted changes to a specific file with git
  • When I do a pull and try to merge my file1 changes back into master, what will happen? Is git smart enough to account for this or will I have to merge my changes manually?

  • Split git diff --name-status by line break
  • Merging release into master with no resulting diff
  • Is there a shortcut for git branch name?
  • How to keep the change log in git files when refactoring in IntelliJ?
  • Git repository on S3 (as “origin”, not as backup)
  • Multiple repos with single submodule
  • 2 Solutions collect form web for “Git merge different file names”

    First, you don’t merge files, you merge revisions (or rather lines of development).

    Second, git uses similarity based heuristic to detect renames, so if file2 is similar enough to file1, then git should automatically merge your and his changes into file2. If not, you would get ‘CONFLICT(modify/delete)’ (I think) you would have to resolve manually.

    It depends…. was there a git mv file1 file2 did git recognize this as a rename? if it did then it might recognize this… otherwise it will probably just try to create a new file1. you may have to do some manual merge intervention or a post merge patch. Also this is git TIAS worst case scenario you roll back the merge before pushing.

    Git Baby is a git and github fan, let's start git clone.