Jeel Jeel - 1 month ago 6
Git Question

Git migration doesn't work for removed files

We have two Vendors working of the same piece of code. Due to logistics issue both maintain their own instances of git.

We sync the code periodically using the following approach:


  1. git pull from vendor1

  2. add a remote for vendor2

  3. Push to vendor 2

  4. Repeat this process



However, when a file is removed from vendor1 it should be removed for vendor2 as well. But somehow our process is failing to remove the files from vendor2.

Answer

A commit recording a file deletion should delete said file when the branch is pulled and merged in vendor2.

But when a vendor2 contributor update his/her own working tree locally, he/she might still have a copy of that file in the editor, and could save, add and commit again said file.

It is important to clean one own's working tree in order to remove any local file which might be obsolete.

git clean -f -d -x $(git rev-parse --show-cdup)