Home > front end >  Clone from public repository and push to private repository
Clone from public repository and push to private repository

Time:07-01

I have cloned a public repository from github, made some modifications and now I want to push them to a private repo. The steps I took are shown below:

$ git clone -b dev https://github.com/public_repo
$ cd public_repo
## modify files
$ git add .
$ git status
On branch dev
Your branch is up to date with 'origin/dev'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
    new file:   ...
    modified:   ...
    modified:   ...
    ...
$ git commit -m "Now supports new features"
[dev 5f98577c] Now supports Chiplet
 68 files changed, 2855 insertions( ), 1910 deletions(-)
 create mode 100644 ....
$ git remote add private https://private_domain
$ git push private dev
Username for ...
Password for ...
To https://private_domain
 ! [rejected]          dev -> dev (fetch first)
error: failed to push some refs to 'https://private_domain'
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.

Note that the private repository is also on dev branch. How can I fix that?

CodePudding user response:

according to error : you have different code on the private repo dev branch and you're trying to push some other changes without taking pull . please try to take pull before push

  • Related