Reputation: 5258
I have the following setup: I am working on a PHP application deployed on a development server, but am editing the files on my local PC and uploading them one by one when they are changed. I could of course commit and push every single change and pull it to the server, but uploading them without involving git is far more convenient (I have a keyboard shortcut configured for it in my IDE). So, when I eventually commit & push my changes and pull them on the server, I will have the exact same changes in the "working copy" on the server and in the files I am trying to pull, but git will still tell me that there are conflicts and will refuse to pull the changes. Is there a way to handle this situation automatically? I can do git checkout *
before git pull
on the server, but in case there are some changes which are only on the server (unlikely, but who knows), these would then be lost, so this solution is not ideal...
Upvotes: 0
Views: 149
Reputation: 5258
Based on @LeGEC's answer, I now created a shell alias on the development server:
alias gitdiff='git fetch; git diff @{upstream}'
This fetches the changes from origin and then shows any differences between the working copy and the upstream version of the branch (ignoring the "local" version of the branch which isn't yet updated). So I can now type gitdiff
and if it doesn't show any differences I know I can safely run git checkout .
and git pull
to have everything up to date.
Upvotes: 0
Reputation: 52006
note : your workflow seems awkward, you may want to look into how you deploy.
As far as git is concerned :
You can always run git fetch
instead of git pull
-- this will only update the origin/*
branches, and try nothing on your active commit -- and then decide what to do :
git diff origin/master
to check what are the differences between your worktree and what you just fetchedgit reset origin/master
, which would move the active commit without modifying (at all) the files in your worktree,git checkout .
or git reset --hard HEAD
to discard all differences with the commit's contentUpvotes: 1