Git only can version files that are inside the root directory of the repository. The tree you depict suggests that your "Unpackaged Folder" pull is a separate directory hierarchy outside of your repository. You'll need to move the retrieved files into your
MasterRepo directory tree before you'll be able to
git add them.
Git by itself is not really a file manager. You can do things like
git rm and
git mv to execute a file system operation (delete and move, respectively), but they don't work on files that aren't already under version control (they're just conveniences). You'll need to use your OS's file manager to integrate your trees.
Salesforce DX and Retrievals
If you're using the
force:source:retrieve command for working with new-format source code against a sandbox, all you need to do is execute
sfdx force:source:retrieve -x package.xml -u email@example.com
within your SFDX project folder, which should also be your Git folder. SFDX automatically routes all pulled metadata to the right subfolders of the project and overwrites any changed files with new versions. Immediately after performing the pull, you can run
to see what's been updated before you construct your commit.
If you're using the SFDX Metadata API commands, the behavior is a little bit different, but can still handle much of the merge for you.
Running these commands from the root of your SFDX project will pull and convert MDAPI source, integrating it into your project tree:
sfdx force:mdapi:retrieve -u firstname.lastname@example.org -k package.xml --retrievetargetdir mdapi
unzip -d mdapi/src mdapi/unpackaged.zip
sfdx force:mdapi:convert -r mdapi/src
Note that unlike
force:mdapi:convert command won't overwrite existing files - it'll rename them with
.dup and you'll have to manually resolve which version you want.
If you are not using new-format source code, you'll only be working with
force:mdapi:retrieve. This command
Uses Metadata API to retrieve a .zip of XML files that represent metadata from the targeted org.
Hence, you'll still have to deal with unzipping the package and merging the results into your Git tree. The details of how to do so will depend on what archive tool you have available and your operating system. Alternately, you might choose to use a different Metadata API tool. The details would really belong to another question once you've had a chance to explore.