I would like to "self-update" my php app with git. The app should fetch the latest code from the remote repository (github) and overwrite the local code.
It should do the following:
- Fetch the latest code from remote (only master branch)
- overwrite the local code (including any unstaged changes)
- it must not overwrite/delete anything listed in gitignore
- it should show a diff of all the files that have changed (for logging purposes)
At the moment i'm using the following commands:
git fetch origin master
git diff master origin/master --stat
git reset --hard origin/master
This works, as it fetches the latest code from the remote and overwrites all the latest changes. The problem is, that git diff
also shows some old changes and I need it to show just the latest changes.