Reputation: 701
Currently, as I learn git (total newbie), I am a one-man show working on a local master repo then pushing changes to a remote master repo after committing and testing. That works great. No one else is involved.
Now, this may sound like madness to the seasoned, but on occasion I've made a quick change to a file directly to files on the server using sFTP, say myfile.html
Doing so leaves me in a situation where myfile.html
on the remote has a change that I need in my local repo. i.e. the remote file is further ahead than my local version. So...
My question is this: if a file is modified on the remote via ftp, for example, the change isn't registered by git, so how can I get that change via a Fetch/Pull? If I try now, I'm told that local/remote are up-to-date.
Is there a way to speak to the remote to check if it has any changed files that need staged/committed in the way one can do on a local machine?
If not, is there a way, using git, to compare the files on the local remote so I can at least see the difference and drag my edit back down to my local machine?
Upvotes: 1
Views: 52
Reputation: 701
On Chris's advice, I'm posting this answer.
Git is sometimes hosted as Platform as a Service (like Heroku or, in my case, WP-Engine's "Git Push").
Often these installs are basically one-way streets. The idea is that you create a local or distributed git dev environment then Push your files to them when tested. So git push here is a bit like sFTP in that the files go straight to the Production environment (you could be using a staging server too, of course).
However, if a user creates or edits a file directly via FTP or through a web interface, it will not be available to stage and commit using this type of system. When you git pull/fetch you'll be told your files are up to date even though they aren't because there is no difference between what git sees on the server and in your repo.
In short, in such platforms, git doesn't watch out for what you do outside of git.
If you have made remote changes via sFTP then download them via sFTP to your local install to update the local file, then stage and commit it back up so it enters the repo.
On other platforms, like Github, the environment is controlled so you can only change files via methods that git is aware of. So you're not going to create files that are outside of git's awareness.
Finally, if you're running git on your own (or hosted) server, you could "more or less" (I'm not an expert) terminal in as a user on the server, check for unstaged changes and commit just like on a local machine. If you need to do that, I'm sure the experts on this forum can help.
Upvotes: 1