Wrong branch on the server
See original GitHub issueWhen I ran pm2 deploy package.json production setup
locally, ssh into the server and go to the source folder, I see it’s not the production
branch but a different branch.
In package.json I have clearly defined two different environments with their two different branches. Yet it does not work well:
"deploy": {
"production": {
"user": "nodejs",
"host": "blahblah",
"port": "2222",
"ref": "origin/master",
"repo": "git@github.com:binarykitchen/xxx.io.git",
"path": "/var/www/xxx/production",
"post-deploy": "npm run-script init-production"
},
"staging": {
"user": "nodejs",
"host": "blahblah",
"port": "2222",
"ref": "origin/staging",
"repo": "git@github.com:binarykitchen/xxx.io.git",
"path": "/var/www/xxx/staging",
"post-deploy": "npm run-script init-staging"
}
},
Any ideas or suggestions why? Or could it be a bug?
Issue Analytics
- State:
- Created 9 years ago
- Comments:12 (1 by maintainers)
Top Results From Across the Web
What to do when you commit to the wrong Git branch pt. 2
The golden rule is to: Never rewrite the history of a branch that you have already pushed to a Git server and shared...
Read more >Git pulled from wrong branch - Stack Overflow
I have two branches on the server A branch called R2 and a branch called DEV I inadvertently logged into the wrong server,...
Read more >Git tip: how to fix an accidental commit on the wrong branch
Oh no, you just accidentally commited to master , when you were supposed to work on a feature branch! How to fix it?...
Read more >Fixing things when you push changes to the wrong branch on ...
You've git pushed commits to the wrong branch on github. How do you use git to revert them safely and get your project...
Read more >Git tag set on wrong branch - Visual Studio Feedback
Please also check in your local give repository, run the 'gitk --all' command. It shows clearly which tag point to which commits and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was having a similar issue, I think I tracked down the issue: https://github.com/Unitech/pm2-deploy/blob/master/deploy#L236
run "cd $path/source && git fetch --all --tags"
From
git
help:When you specify
--tags
, the regular branches are not updated. When attempting to deploy, it was not updating the source code to the latest in myorigin/develop
branch despite having specified that as theref
. I discovered this by runninggit fetch --all
on the server and noticed that it finally dowloaded the updates. I added the line below to the deploy config and ran it by hand once on the server to pull down the latest config changes. Now it will pull down all updates before it does thegit reset --hard
which does update based on the most recently fetched commits as @rchan-pp mentioned:I suspect this is a bug as it prevents you from checking out a commit/branch that is ahead of where the server has previously fetched. I hope that helps.
This looks like it could be related to this issue: https://github.com/Unitech/pm2/issues/3803