I'm using git to track a project, and if it's possible, I'd like to set things up so git handles all my code staging, I can have a local repository for testing, and then push changes to the server with git to make them live. However, in trying to use standard git push
calls, I just end up with inconsistent branching and a terrible mess of conflicting histories. Is there a way to manage staging using git?
To check if you're up-to-date with GitHub run git fetch origin before git status and you'll know you're up-to-date.
A remote in Git is a common repository that all team members use to exchange their changes. In most cases, such a remote repository is stored on a code hosting service like GitHub or on an internal server. In contrast to a local repository, a remote typically does not provide a file tree of the project's current state.
You have in this blog post an example of Git repo used for staging:
IDE => local Git repository => remote bare Git repository
=> Git repository with the live web application
It involves a post-update hook on the bare repo side, in order to trigger the update of the repo on the live web server side.
The final step is to define the “post-update” hook script on the bare repository, which is called when the bare repository receives data.
To enable the “post-update” hook, we have to either makehooks/post-update
executable or renamehooks/post-update.sample
tohooks/post-update
, depending on the Git version.
In this script, we simply change to the folder of the live application, and start the pull operation:
#!/bin/sh
cd $HOME/example.org
unset GIT_DIR
git pull bare master
exec git-update-server-info
The reason there is a bare remote repo is because it is “discouraged” to do a push into a repo with a working directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With