I created Git remote
to push commits to a Github repository (github) and to a bare
repository (droplet) that automatically deploy code to /var/www/myapp
thanks to Git hooks
.
The idea is to enter git push droplet
and git push github
to push commits in the server (droplet) and to the central repo (github).
Now, when I enter git push droplet
it push the commits to the server but when I enter git push github
it says there is nothing to commit because the branch is up-to-date, but it’s not. I checked the Github repository and see that the last commit is 4 months old.
How could I update the code base in my Github account ?
Git remote
$ git remote -v
droplet admin@droplet-myapp:/home/admin/repo/MyApp.git (fetch)
droplet admin@droplet-myapp:/home/admin/repo/MyApp.git (push)
github git@github.com-MyApp:MyApp/MyApp.git (fetch)
github git@github.com-MyApp:MyApp/MyApp.git (push)
Git config
$ more config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "github"]
url = git@github.com-MyApp:MyApp/MyApp.git
fetch = +refs/heads/*:refs/remotes/github/*
[user]
name = MyApp
email = florent@myapp.com
[branch "master"]
[remote "droplet"]
url = admin@droplet-myapp:/home/admin/repo/MyApp.git
fetch = +refs/heads/*:refs/remotes/droplet/*
[branch "master"]
remote = droplet
merge = refs/heads/master
Git push (which fail to update codebase)
$ git add . && git commit -m 'fix' && git push github
On branch master
Your branch is up-to-date with 'droplet/master'.
nothing to commit, working tree clean
>Solution :
Problem lies in this line
git add . && git commit -m 'fix' && git push github
You are trying to stage files. Than if this succeeded – commit files. And than if commit succeeded – push them to github.
Since you already committed you changes previously git commit fails, and push is not executed.
Use only git push github
instead.