1. git remote show origin or git config --get remote.origin.url
2. git remote add origin ssh://email@example.com/your-user-id/your-project.git
3. Add the ssh key of the server to bitbucket SSH keys.
4. Login to the server and from the rails project current directory change the git remote by running the command in step 2.
Since I am using Moonshine, I had to delete the cached-copy folder on the server. Because it points to github and creates problem when cap deploy is run.