I have a microservices application, so the front-end on the first repo and two different backend APIs on two different repos. I want to add all these to someone else's empty repo and I am not sure how to do this.
I tried doing a git remote add of the other persons repo and I get this:
danales-MacBook-Pro:freelance-camp-fe danale$ git remote add https://github.com/Meridian-Business-Centers/Interview-Sample-App.git
usage: git remote add [<options>] <name> <url>
-f, --fetch fetch the remote branches
--tags import all tags and associated objects when fetching
or do not fetch any tag at all (--no-tags)
-t, --track <branch> branch(es) to track
-m, --master <branch>
master branch
--mirror[=<push|fetch>]
set up remote as a mirror to push to or fetch from
When I do a git remote add microservice master I get this error:
danales-MacBook-Pro:freelance-camp-fe danale$ git push microservice master
remote: Permission to Meridian-Business-Centers/Interview-Sample-App.git denied to ldco2016.
fatal: unable to access 'https://github.com/Meridian-Business-Centers/Interview-Sample-App.git/': The requested URL returned error: 403
I tried pushing it to my own forked version and got this error:
danales-MacBook-Pro:freelance-camp-fe danale$ git remote add microservice https://github.com/ldco2016/Interview-Sample-App.git
fatal: remote microservice already exists.
danales-MacBook-Pro:freelance-camp-fe danale$ git push microservice master
To https://github.com/ldco2016/Interview-Sample-App.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/ldco2016/Interview-Sample-App.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.
danales-MacBook-Pro:freelance-camp-fe danale$ git push -u microservice master
To https://github.com/ldco2016/Interview-Sample-App.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/ldco2016/Interview-Sample-App.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.
Go into every separate repo and add a remote (say, personal) with the url of other persons empty github repo. Now push the code like git push personal master.
Say, you have repo1, repo2 and repo3. And a personal repo perRepo (want to add repo1, repo2 and repo3 codes here).
# Go into repo1
$ git checkout master
$ git remote add personal <perRepo-url>
$ git push personal master
# Go into repo2
$ git checkout master
$ git remote add personal <perRepo-url>
$ git push personal master
# Go into repo3
$ git checkout master
$ git remote add personal <perRepo-url>
$ git push personal master
Add Submodule: General command: git submodule add <git#XXX:YYY> <externals>.
git submodule add: Simply tells Git we are adding a submodule
git#XXX:YYY: External repository URL that is to be added as a submodule
externals: This is the path where the submodule repository will be added to the main repository.
More Submodule
Add repo1, repo2 and repo3 as submodule of perRepo.
# Go into perRepo
$ git submodule add <repo1-url> <path>
$ git submodule add <repo2-url> <path>
$ git submodule add <repo3-url> <path>
$ git submodule update --init --recursive
N.B. when repo1/repo2/repo3 would be updated you need to run git submodule update command to get the updated changes into perRepo repo.
Related
I can't update the source code in the repository on github.com using the following command.
$ git push -u origin master
The following error is displayed:
! \[rejected\] master -\> master (fetch first)
error: failed to push some refs to 'https://github.com/\<username\>/my-history.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.
Is there any way to do this?
I want to push the source code in the my repository.
I experienced something similar to this a few days ago.
You can do something like this:
$ git remote add origin https://github.com/username/my-repo.git
$ git push -f origin master
When I use git init it only shows (master) and not (master -> origin), and then that when I use the command: git push -u origin master it returns an error:
error: src refspec master does not match any.
error: failed to push some refs to 'github.com:BghAek/something.git'
Most probably this happened:
Forget to add the remote repo link
You have created a new repository using the init command, but it looks like you forgot to add the link to the remote repository. So do the following:
Remove the `.git` file from you local system.
Create a clean repository using the following:
git init
git add .
git commit -m "COMMIT MESSAGE"
git branch -M main
git remote add origin REMOTE_REPOSITORY_LINK
git push -u origin main
replace REMOTE_REPOSITORY_LINK with that of the remote repository link. Remember your are on main branch, so as to keep it consistent with the remote branch( read more here).
Early I had only github repository, but now want used both github and bitbucket.
I added a new remote git repository on Bitbucket, use git remote set-url.
git remote -v show
origin https://github.com/My/remont (fetch)
origin https://github.com/My/remont (push)
origin https://my#bitbucket.org/my/remont.git (push)
Then run:
git add --all .
git commit -m "bitbucker"
git push -u origin master
Github added fine but bitbucket shows an error
Password for 'https://my#bitbucket.org':
To https://bitbucket.org/my/remont.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://my#bitbucket.org/my/remont.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.
Trying to push a committed file to an existing remote repository on GitHub.
Below I verified and I'm trying to push to the Django. I've tried git push, and git push -u Django master. Any help would be appreciated. I have been saving all of my files locally and I am now adding all to GitHub and it's a little confusing.
Roberts-MBP:Django robertamato$ git remote -v
Django https://github.com/CodingDojo-Python-09-04/Robert_Amato.git (fetch)
Django https://github.com/CodingDojo-Python-09-04/Robert_Amato.git (push)
origin https://github.com/CodingDojo-Python-09-04/RobertAmato (fetch)
origin https://github.com/CodingDojo-Python-09-04/RobertAmato (push)
Roberts-MBP:Django robertamato$
Here is a error code it threw, I see it suggests to fetch first but I'm not to familiar with how that process works.
Roberts-MBP:Django robertamato$ git push -u Django master
To https://github.com/CodingDojo-Python-09-04/Robert_Amato.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/CodingDojo-Python-09-04/Robert_Amato.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.
Why do I see an error message when typing git remote add?
$ git remote add origin remote repository https://github.com/hashanmalawana/Loginsystem.git
usage: git remote add [<options>] <name> <url>
-f, --fetch fetch the remote branches
--tags import all tags and associated objects when fetching
or do not fetch any tag at all (--no-tags)
-t, --track <branch> branch(es) to track
-m, --master <branch>
master branch
--mirror[=<push|fetch>]
set up remote as a mirror to push to or fetch from
You should type:
git remote add origin https://github.com/hashanmalawana/Loginsystem.git
not
git remote add origin remote repository https://github.com/hashanmalawana/Loginsystem.git
^^^^^^^^^^^^^^^^^^
That way, you add a remote named origin, referencing the remote repo https://github.com/hashanmalawana/Loginsystem.git
And you won't see the usage message
usage: git remote add [<options>] <name> <url>
I understand that the step 8 of "Adding an existing project to GitHub using the command line" can be confusing:
git remote add origin remote repository URL
But the last three parameters are actually only one. It should read:
git remote add origin <remote repository URL>
It is better to refer to the actual man page for git remote
git remote add <name> <url>