How to pull changes from different working directory?

I’m only just taking my first steps with Git and managed to push my code to a new Github repository. A friend has been working on this same code an made some major refactors. I want to just try and see what comes out when I merge her changes into my version with Git.
I have my friend’s code in a local folder different from the one I wrote my code in.
Now how can I push it to the repository, performing a merge remotely?

Was your friends directory just cloned from yours? If the directory itself is a git repository and you have it saved locally then this should be fairly straightforward. You’d just need to check if you have remote tracking set up correctly (for this second local repo) which is under git remote, use the -v flag to see a little more detail for upstream/downstream details. If it’s not set-up then add it in the same way you did for the first repo how to: add a remote from the docs.

After that it may be as simple as git push to just update the online repo (you’d probably then want to remove one of these local repos). If the commits have diverged (e.g. your continued on your own work whilst your friend worked on theirs) then it might be a bit trickier and you may be forced to tease out any overlapping changes (your history could be a bit messier).

Alternatively you could avoid having multiple locally linked directories to the same online store by adding a remote from your first directory to your friend’s newer directory on your own machine and pull any changes into your main local repo before pushing to the online store but with the same caveats regarding divergence.

If your friend’s directory isn’t managed by git at all then I’d personally aim to do all changes locally as I’m not comfortable enough with git to try and deal with that kind of mess remotely (it sounds problematic especially if you wanted to keep your history as clean as possible). In this case you may want to do a bit more research and look at any alternative tools for this task (assuming the changes are complex and you can’t just copy the newer files to your original repo).

In the future it would be worth looking into doing this properly with forking or collaboration.