Push a local file to an existing GitHub remote repo - github

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.

Related

failed to push some refs to 'https://github.com/<username>/my-history.git'

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

Pushing commit to github repository throwing error

The error I am getting:
To https://github.com/Git-Username/Repo.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/user/repo.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Command I am executing:
git push origin master
I have tried nearly everything when I googled this error, I tried pulling etc.
I tried pulling etc.
pulling should have been enough to solve the issue.
But if your local history is correct (git log), and you are the only one pushig to that repository, you could also simply force push
git push --force -u origin master
That will override the history on the remote.

Error message showing while pushing in Git

While i am pushing in Git I am finding the below error
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/smitraDA/DataScienceProject2.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.
I have already Clone,Add -A, and Commit. As follows:
C:\Users\Dell-672206>git clone https://github.com/smitraDA/DataScienceProject2.git
fatal: destination path 'DataScienceProject2' already exists and is not an empty directory.
C:\Users\Dell-672206>cd DataScienceProject2
C:\Users\Dell-672206\DataScienceProject2>git add -A
C:\Users\Dell-672206\DataScienceProject2>git commit -m "version1"
I am finding the below error:
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/smitraDA/DataScienceProject2.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.
In this situation, you have to fetch your data first from GitHub and pull all the changes from GitHub to your local repository AND then push to a remote repository. You can use the below commands:
$ git pull origin master
$ git push origin master

Bitbucket and Git same time push error

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.

How do I add my repos to another persons repo?

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.