I have an existing repository in Github then I have decided to host this repository also bitbucket and gitlab.
Then I add a remote repository of GitLab and bitbucket to the git config and successfully push to multiple servers. Push is working when changing on local machine/pc and GitHub also working when changing on GitHub online server and pull commit and push again to all remote servers.
The problem is when I have changed any code from bitbucket or GitLab and then try to pull to a local machine/pc it not pulling. So, I have changed something in my local machine/pc then after commit tries to push but the push is working only GitHub and Gitlab Bitbucket push not working (not updating remote repositories).
asifulmamun@asifulmamun:~/script/Youtube-Projects$ git push
Everything up-to-date
To bitbucket.org:asifulmamun/youtube-projects.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to '[email protected]:asifulmamun/youtube-projects.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
To gitlab.com:asifulmamun/youtube-projects.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to '[email protected]:asifulmamun/youtube-projects.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Gitlab and Bitbucket remote server telling me to pull the repository then try to for the push. But, the pull not working. Showing me all up to date because this pull is working only for GitHub, not for Bitbucket and Gitlab.
asifulmamun@asifulmamun:~/script/Youtube-Projects$ git pull
Already up to date.
However, if the pull not working from Bitbucket or Gitlab server how I will push them again after changing something from local repositories.
Any solution?
CodePudding user response:
You could set two different remotes
(tracked repositories) to your project:
git remote add bitbucket <the_path_for_bitbucket_project>
git remote add gitlab <the_path_for_gitlab_project>
Then, whenever you want to pull from bitbucket
for instance, you could run:
git pull bitbucket <branch_name>
Then if you want to push something to gitlab
for instance, you could run:
git push gitlab <branch_name>