Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add Existing Project To Git Repo

#Adding an existing project to GitHub using the command line

Simple steps to add existing project to Github.

1. Create a new repository on GitHub.

In Terminal, change the current working directory to your local project.

##2. Initialize the local directory as a Git repository.

git init

Add the files in your new local repository. This stages them for the first commit.

git add .

or:

git add --all

Commit the files that you've staged in your local repository.

git commit -m 'First commit'

Copy remote repository URL field from your GitHub repository, in the right sidebar, copy the remote repository URL.

In Terminal, add the URL for the remote repository where your local repostory will be pushed.

git remote add origin <remote repository URL>

Sets the new remote:

git remote -v

Push the changes in your local repository to GitHub.

git push origin master

Pushes the changes in your local repository up to the remote repository you specified as the origin

@eds-satish

This comment has been minimized.

Copy link

@eds-satish eds-satish commented Aug 2, 2017

thank you it worked for me.

@MnTronslien

This comment has been minimized.

Copy link

@MnTronslien MnTronslien commented Aug 15, 2017

Does this work when migrating an existing project as well?

@lreiner

This comment has been minimized.

Copy link

@lreiner lreiner commented Aug 17, 2017

Thank you worked for me too

@isaacayz

This comment has been minimized.

Copy link

@isaacayz isaacayz commented Sep 6, 2017

It's giving me errors.

@andikaerwansyah

This comment has been minimized.

Copy link

@andikaerwansyah andikaerwansyah commented Sep 18, 2017

it works perfectly, thanks, man.

@AnujGangwal

This comment has been minimized.

Copy link

@AnujGangwal AnujGangwal commented Sep 20, 2017

Worked for me, thanks.

@Elijah23Johnson

This comment has been minimized.

Copy link

@Elijah23Johnson Elijah23Johnson commented Sep 24, 2017

Worked for me

@jurgens37

This comment has been minimized.

Copy link

@jurgens37 jurgens37 commented Oct 4, 2017

I enter : git push origin master
then : I don't handle 'https'

how to fix it ?

@nirmalsi

This comment has been minimized.

Copy link

@nirmalsi nirmalsi commented Nov 1, 2017

can i change from master branch.

@AyoubGharbi

This comment has been minimized.

Copy link

@AyoubGharbi AyoubGharbi commented Nov 11, 2017

Thanks :)

@kevoh3

This comment has been minimized.

Copy link

@kevoh3 kevoh3 commented Nov 16, 2017

it works for me thanks

@charlescampista

This comment has been minimized.

Copy link

@charlescampista charlescampista commented Nov 26, 2017

I got an error.
So I've changed "git push origin master" for this "git push -f github master".
it works well for me.

@OldboyJ

This comment has been minimized.

Copy link

@OldboyJ OldboyJ commented Nov 28, 2017

It completely worked for me..
👍

@TarunKShukla

This comment has been minimized.

Copy link

@TarunKShukla TarunKShukla commented Nov 30, 2017

It's really helpful.Thanks

@keshari1arya

This comment has been minimized.

Copy link

@keshari1arya keshari1arya commented Dec 2, 2017

remote: Permission to keshari1arya/Lipun.git denied to arya-choudhury.
fatal: unable to access '{my url}': The requested URL returned error: 403

i am getting this error while pushing. please help me

@benoitrolland

This comment has been minimized.

Copy link

@benoitrolland benoitrolland commented Dec 2, 2017

Had to force, because remote project seems to have its own history (automated Licence.md and README.md creation ?):
git push -f origin master

@TimEaleifo

This comment has been minimized.

Copy link

@TimEaleifo TimEaleifo commented Dec 5, 2017

Hi,
This didn't work for me. i got the message below-- please any solution

C:\Tim\source\repos>git push -u origin master
To https://github.com/hester/TimSSIS.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/hester/TimSSIS.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.

@Zerka1982

This comment has been minimized.

Copy link

@Zerka1982 Zerka1982 commented Dec 7, 2017

Hello TimeEaleifo,

You can simply create a new repository without adding README.MD or gitignore files.
Then move your project to another folder. Right click on the project and choose "Git Bash here". Run the following command lines :

1- git init
2- git add .
3- git commit -m "first commit"
4- git remote add origin "remote repository URL"
5- git push origin master

I hope this will help u solving the problem. Good Luck!

@zhaohany

This comment has been minimized.

Copy link

@zhaohany zhaohany commented Dec 15, 2017

! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/zhaohany/Rutgers-CS211.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.

@SalathielGenese

This comment has been minimized.

Copy link

@SalathielGenese SalathielGenese commented Jan 4, 2018

Please, wrap "First commit" around double quotes.

Thanks for sharing.

@deepakrishnan90

This comment has been minimized.

Copy link

@deepakrishnan90 deepakrishnan90 commented Jan 19, 2018

error: src refspec Regression does not match any.

I am getting above mentioned error. Please help

@weitzhandler

This comment has been minimized.

Copy link

@weitzhandler weitzhandler commented Jan 23, 2018

Can't get it to work:

D:\Users\Shimmy\Source\Repos\MyRepo>git push origin master
To https://github.com/weitzhandler/MyRepo.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/weitzhandler/MyRepo.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.

D:\Users\Shimmy\Source\Repos\MyRepo>
@polvilarrasa

This comment has been minimized.

Copy link

@polvilarrasa polvilarrasa commented Jan 25, 2018

i don't understand what i have to do in this part:
Copy remote repository URL field from your GitHub repository, in the right sidebar, copy the remote repository URL.

In Terminal, add the URL for the remote repository where your local repostory will be pushed.

i am quite new to this

@mtalha91

This comment has been minimized.

Copy link

@mtalha91 mtalha91 commented Feb 3, 2018

I am having an error when push: Fatal error: no repository found. I have also check whether I have successfully setup ssh key

@franzabgrund

This comment has been minimized.

Copy link

@franzabgrund franzabgrund commented Feb 7, 2018

Hi, after command git commit -m "first commit" I get the following error:

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address 
@abykal

This comment has been minimized.

Copy link

@abykal abykal commented Feb 11, 2018

I had the same as @TimEaleifo, while pushing.

Force push worked.
git push -u -f origin master

@Divi28

This comment has been minimized.

Copy link

@Divi28 Divi28 commented Feb 13, 2018

Thank you..It Worked for me :)

@ngarciaiii

This comment has been minimized.

Copy link

@ngarciaiii ngarciaiii commented Feb 25, 2018

abyabrkal's worked for me. :) Thanks!

@danipralea

This comment has been minimized.

Copy link

@danipralea danipralea commented Mar 9, 2018

thank you! worked!

@lukehinds

This comment has been minimized.

Copy link

@lukehinds lukehinds commented Apr 19, 2018

So this is for importing existing code, not an existing git repo with a .git set of files already present.

@AlexayEugine

This comment has been minimized.

Copy link

@AlexayEugine AlexayEugine commented Apr 21, 2018

I have some issue:

E:\GitLab\proguiden\laravel.proguiden.no>git push origin master
To https://gitlab.com/FantasyLab/laravel.proguiden.no.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitlab.com/FantasyLab/laravel.proguiden.no.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.

How can I solve it?

@bufpal

This comment has been minimized.

Copy link

@bufpal bufpal commented May 6, 2018

Thank you, it worked for me too :)

@timzzy

This comment has been minimized.

Copy link

@timzzy timzzy commented Jun 11, 2018

Workss....whoolaaaaa

@emoonadev

This comment has been minimized.

Copy link

@emoonadev emoonadev commented Jun 28, 2018

Works fineeee thanks

@sushant-78

This comment has been minimized.

Copy link

@sushant-78 sushant-78 commented Jul 16, 2018

thanks.

@molebox

This comment has been minimized.

Copy link

@molebox molebox commented Aug 3, 2018

Boom! Yes mate, great guide!

@AGudyma

This comment has been minimized.

Copy link

@AGudyma AGudyma commented Aug 8, 2018

cool very useful, simple to understand and to use. Thanks Dude!

@urwa

This comment has been minimized.

Copy link

@urwa urwa commented Aug 17, 2018

FOR FUTURE READERS

! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/zhaohany/Rutgers-CS211.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.

This can be solved by using git push -f origin master instead of git push origin master OR creating a repo on github.com WITHOUT a readme.md

*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address

This can be solved by running above two commands by replacing you@example.com with your email id and Your Name by your name on github.com. Both of these can be found on your github.com profile or settings

error: pathspec 'Commit' did not match any file(s) known to git.

This can be resolved by using " " around Commit like this git commit -m "First Commit"

Copy remote repository URL field from your GitHub repository, in the right sidebar, copy the remote repository URL.
In Terminal, add the URL for the remote repository where your local repository will be pushed.

This is simply telling you to go to your repo on github.com where you want to move your code files and simply copy the URL. Ignore the sidebar thing etc ( I didn't get it myself )

Hope it helps.

@ZoeyOneOhOne

This comment has been minimized.

Copy link

@ZoeyOneOhOne ZoeyOneOhOne commented Sep 12, 2018

I get this error, "bash: syntax error near unexpected token `newline'" what does this mean?

@oudoulj

This comment has been minimized.

Copy link

@oudoulj oudoulj commented Sep 28, 2018

For Windows users, whenever you see single quotes in the guide above, replace them with double quotes eg
git commit -m "First commit"

@akanshamalik

This comment has been minimized.

Copy link

@akanshamalik akanshamalik commented Oct 9, 2018

i am not able to add files, it says this:
error: open(".cache/tilda/locks/lock_3846_0"): Permission denied
error: unable to index file .cache/tilda/locks/lock_3846_0
fatal: adding files failed

@leminhhung

This comment has been minimized.

Copy link

@leminhhung leminhhung commented Nov 22, 2018

Thanks, work for me!

@orionhall

This comment has been minimized.

Copy link

@orionhall orionhall commented Jan 26, 2019

Hi, I just tried to do this on my own and I believe I followed the same steps, but when I tried to push I was told I had to pull (probably because I initialized the repo with a readme file), and on doing that was told it couldn't be done because of "cannot merge unrelated histories". I eventually pulled with allow-unrelated-histories, but then had to enter a message as to why I was merging, etc. Is this because I added the readme file or does anyone else know what I may have done wrong?

@awg01

This comment has been minimized.

Copy link

@awg01 awg01 commented Feb 15, 2019

It worked...!!
Thanks for such a nice tutorial.

@veerpalk

This comment has been minimized.

Copy link

@veerpalk veerpalk commented Feb 22, 2019

Hi,
This didn't work for me. i got the message below-- please any solution

C:\Tim\source\repos>git push -u origin master
To https://github.com/hester/TimSSIS.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/hester/TimSSIS.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.

Hi , You can use command:
git push origin master --force

@prashant1k99

This comment has been minimized.

Copy link

@prashant1k99 prashant1k99 commented Mar 1, 2019

can i change from master branch.

git remote add github https://github.com/username/repo.git
It will add github as your commit name.
So if you want to commit to github...git push github

You can even connect multiple platforms with the single Repo..

@prashant1k99

This comment has been minimized.

Copy link

@prashant1k99 prashant1k99 commented Mar 1, 2019

I have some issue:

E:\GitLab\proguiden\laravel.proguiden.no>git push origin master
To https://gitlab.com/FantasyLab/laravel.proguiden.no.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitlab.com/FantasyLab/laravel.proguiden.no.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.

How can I solve it?

You need to make some additional changes to the push or need to add commit before performing the Push.

@prashant1k99

This comment has been minimized.

Copy link

@prashant1k99 prashant1k99 commented Mar 1, 2019

Hi, after command git commit -m "first commit" I get the following error:

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address 

You need to authenticate first then the commit will be accepted.

@buerlee

This comment has been minimized.

Copy link

@buerlee buerlee commented Mar 1, 2019

Had to force, because remote project seems to have its own history (automated Licence.md and README.md creation ?):
git push -f origin master

It works. Thanks.

@AlessandraZullo

This comment has been minimized.

Copy link

@AlessandraZullo AlessandraZullo commented Mar 14, 2019

Hi,
This didn't work for me. i got the message below-- please any solution

C:\Tim\source\repos>git push -u origin master
To https://github.com/hester/TimSSIS.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/hester/TimSSIS.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.

git push -f origin master

@KidOfCubes

This comment has been minimized.

Copy link

@KidOfCubes KidOfCubes commented Apr 24, 2019

It works, thx :D

@KidOfCubes

This comment has been minimized.

Copy link

@KidOfCubes KidOfCubes commented Apr 24, 2019

It works, thx :D

@RikTheGuy

This comment has been minimized.

Copy link

@RikTheGuy RikTheGuy commented May 23, 2019

Thanks

@mattpenner

This comment has been minimized.

Copy link

@mattpenner mattpenner commented May 24, 2019

Perfect! I use VS Code and attempted to do the commands from the Command Pallet, but most of the parameters mentioned above weren't recognized so I resorted to doing those commands in the terminal. Worked great.

@syamsidhardh

This comment has been minimized.

Copy link

@syamsidhardh syamsidhardh commented Jun 12, 2019

How to migrate an existing project from git kernel to github without loosing the commit log history.
For ex: https://git.kernel.org/pub/scm/bluetooth/bluez.git to https://github.com/username/bluez.git with all the commit history preserved

@vadramson

This comment has been minimized.

Copy link

@vadramson vadramson commented Jun 17, 2019

To Initialize your local project directory as a Git repository;
-> Open your command prompt and navigate to the project directory
-> Then enter

git init

Add the files in your new local repository. This stages them for the first commit.

git add .
or:

git add --all
Commit the files that you've staged in your local repository.

git commit -m 'First commit'
Copy remote repository URL field from your GitHub repository, in the right sidebar, copy the remote repository URL.

In Terminal, add the URL for the remote repository where your local repostory will be pushed.

git remote add origin
Sets the new remote:

git remote -v
Push the changes in your local repository to GitHub.

git push origin master
Pushes the changes in your local repository up to the remote repository you specified as the origin

@mdhe1248

This comment has been minimized.

Copy link

@mdhe1248 mdhe1248 commented Jul 5, 2019

I have some issue:

E:\GitLab\proguiden\laravel.proguiden.no>git push origin master
To https://gitlab.com/FantasyLab/laravel.proguiden.no.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitlab.com/FantasyLab/laravel.proguiden.no.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.

How can I solve it?

I think this issue occurs when the newly generate remote repository (or existing repository) already contains some files (e.g. readme.md and .gitignore). One solution is to use git push -f origin master.
Another solution may be to run git pull origin master. This way, you can keep the existing remote files.
Before running the commands below, it might be safer to create a new branch. There is possibility of having some problems.

In your local project directory e.g.) cd /home/usr/new_project,

  1. git init
  2. git remote add origin your_github_repository
  3. git pull origin master
  4. git add --all
  5. git commit -m "First commit"
  6. git push origin master
@alejoes

This comment has been minimized.

Copy link

@alejoes alejoes commented Jul 25, 2019

I'm trying to do it through Github Desktop and the click label does not change color so I can click and proceed

@zneti-sourour

This comment has been minimized.

Copy link

@zneti-sourour zneti-sourour commented Aug 2, 2019

hi , when i do the cmd ( git remote add origin )i have this message:
fatal: remote origin already exists.
what do you think the problem is ?

@mdhe1248

This comment has been minimized.

Copy link

@mdhe1248 mdhe1248 commented Aug 2, 2019

hi , when i do the cmd ( git remote add origin )i have this message:
fatal: remote origin already exists.
what do you think the problem is ?

My guess is the origin has already been added.
git remote -v will give you the list of origin. Assuming that you have already added the origin, it may be okay to skip to the next step.

@Rudra90

This comment has been minimized.

Copy link

@Rudra90 Rudra90 commented Oct 24, 2019

Thanks

@asdbabil

This comment has been minimized.

Copy link

@asdbabil asdbabil commented Oct 26, 2019

@urwa thanks! The -f switch is what I had missing

@loveprotocol

This comment has been minimized.

Copy link

@loveprotocol loveprotocol commented Dec 27, 2019

Thank!

@floreasy

This comment has been minimized.

Copy link

@floreasy floreasy commented Jan 8, 2020

Thanks :)

@esthercamilo

This comment has been minimized.

Copy link

@esthercamilo esthercamilo commented Apr 10, 2020

! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/zhaohany/Rutgers-CS211.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.

git pull origin master --allow-unrelated-histories

@saifur281

This comment has been minimized.

Copy link

@saifur281 saifur281 commented Apr 22, 2020

I had the same as @TimEaleifo, while pushing.

Force push worked.
git push -u -f origin master

hello create a new repository without selecting "Initialize this repository with a README " ..hope it will work

@saifur281

This comment has been minimized.

Copy link

@saifur281 saifur281 commented Apr 22, 2020

I had some issue:
E:\GitLab\proguiden\laravel.proguiden.no>git push origin master
To https://gitlab.com/FantasyLab/laravel.proguiden.no.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitlab.com/FantasyLab/laravel.proguiden.no.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.
How can I solve it?

I think this issue occurs when the newly generate remote repository (or existing repository) already contains some files (e.g. readme.md and .gitignore). One solution is to use git push -f origin master.
Another solution may be to run git pull origin master. This way, you can keep the existing remote files.
Before running the commands below, it might be safer to create a new branch. There is possibility of having some problems.

In your local project directory e.g.) cd /home/usr/new_project,

1. `git init`

2. `git remote add origin your_github_repository`

3. `git pull origin master`

4. `git add --all`

5. `git commit -m "First commit"`

6. `git push origin master`

Hello dear, make sure when you created repository and you must unchecked " Initialize this repository with a README " this field ...

@daniaaalarshad

This comment has been minimized.

Copy link

@daniaaalarshad daniaaalarshad commented Jun 5, 2020

Thank you :)

@jippysquirmwood

This comment has been minimized.

Copy link

@jippysquirmwood jippysquirmwood commented Jun 20, 2020

Love it how people do this stuff. just sorted me after 6 months or so without a commit!

@dwivedithedev

This comment has been minimized.

Copy link

@dwivedithedev dwivedithedev commented Sep 3, 2020

Thank you so much for this. It works wonderfully!

@shubhamp1997

This comment has been minimized.

Copy link

@shubhamp1997 shubhamp1997 commented Sep 22, 2020

One more thing to add, you should do "push --force" to push forcefully and merge it as it will have different files

@BShah5

This comment has been minimized.

Copy link

@BShah5 BShah5 commented Sep 25, 2020

Thank you, it was really helpful.

@dhanushkomari

This comment has been minimized.

Copy link

@dhanushkomari dhanushkomari commented Oct 8, 2020

Thank You. Worked Nicely. :)

@rimvibol

This comment has been minimized.

Copy link

@rimvibol rimvibol commented Nov 7, 2020

can i change from master branch.

Yes, you can push to any branch you want.

@Syed-Hasnain-Askari

This comment has been minimized.

Copy link

@Syed-Hasnain-Askari Syed-Hasnain-Askari commented Nov 19, 2020

fatal: 'master' does not appear to be a git repository
fatal: Could not read from remote repository.

Can anyone tell me how to resolve this issue?

@jaizon2000

This comment has been minimized.

Copy link

@jaizon2000 jaizon2000 commented Dec 2, 2020

fatal: 'master' does not appear to be a git repository
fatal: Could not read from remote repository.

Can anyone tell me how to resolve this issue?

you probably initialized it under a different name.
image
If you named it like the code above, you would have to do
git push origin main instead of git push origin master

Also I found this stackoverflow discussion

@DarraghLally

This comment has been minimized.

Copy link

@DarraghLally DarraghLally commented Dec 2, 2020

Thanks!

@AkashicSeer

This comment has been minimized.

Copy link

@AkashicSeer AkashicSeer commented Dec 3, 2020

This didn't work at all for me. I get this confusing error
error: src refspec master does not match any
error: failed to push some refs to

@AkashicSeer

This comment has been minimized.

Copy link

@AkashicSeer AkashicSeer commented Dec 3, 2020

The info on this page produces the error above. What I got to work was this if anyone else needs it

https://www.digitalocean.com/community/tutorials/how-to-push-an-existing-project-to-github

@werohit

This comment has been minimized.

Copy link

@werohit werohit commented Dec 7, 2020

0 - rm -rf .git (This will clear existing git project setup so you can now setup a fresh account)
1- git init
2- git add .
3- git commit -m "first commit"
4- git remote add origin "remote repository URL"
5- git push origin master

Hola....

@VenkatGopiThokala

This comment has been minimized.

Copy link

@VenkatGopiThokala VenkatGopiThokala commented Dec 15, 2020

Thank you.. 👍

@ermarkar

This comment has been minimized.

Copy link

@ermarkar ermarkar commented Dec 21, 2020

I have repo of size 9GB. So while cloning if my network, disconnect even for a second, i have to clone it from scratch, so ultimately not able to clone it at all.
So if i download the repo (this will give me the option to resume the download).

and then i do

git init
git remote add origin
git pull
will this work?

i don't want to push any changes to the repo.

@DeraDeveloper

This comment has been minimized.

Copy link

@DeraDeveloper DeraDeveloper commented Dec 23, 2020

This was helpful. Thanks

@hasii2011

This comment has been minimized.

Copy link

@hasii2011 hasii2011 commented Feb 5, 2021

This is great. Keeps these instructions exactly as you have them

@NicolaRamazzotti

This comment has been minimized.

Copy link

@NicolaRamazzotti NicolaRamazzotti commented Feb 16, 2021

Thanks dude

@josuevalrob

This comment has been minimized.

Copy link

@josuevalrob josuevalrob commented Mar 14, 2021

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.

Force it:
git push --set-upstream origin master --force

@Dhineshamt

This comment has been minimized.

Copy link

@Dhineshamt Dhineshamt commented Apr 14, 2021

It worked for me. Thank you so much!!

@shivamaugurs12112

This comment has been minimized.

Copy link

@shivamaugurs12112 shivamaugurs12112 commented Apr 29, 2021

worked! thanks

@singhhimanshu2009

This comment has been minimized.

Copy link

@singhhimanshu2009 singhhimanshu2009 commented May 2, 2021

I'm creating my all projects through superuser, I'm unable to push code to github. Please help.

@j-saurabh

This comment has been minimized.

Copy link

@j-saurabh j-saurabh commented May 14, 2021

It is creating a branch 'master' and that branch I am not able to merge into the 'main' branch. (It show nothing in common so cannot merge)
Sorry if it is a silly question, but I am trying this thing and stuck since many days. Any help would be much appreciated.

@mdhe1248

This comment has been minimized.

Copy link

@mdhe1248 mdhe1248 commented May 14, 2021

I'm creating my all projects through superuser, I'm unable to push code to github. Please help.

This might be helpful?
https://github.com/git-guides/git-push
Especially, "Why can't I push?" in the link above.

@mdhe1248

This comment has been minimized.

Copy link

@mdhe1248 mdhe1248 commented May 14, 2021

It is creating a branch 'master' and that branch I am not able to merge into the 'main' branch. (It show nothing in common so cannot merge)
Sorry if it is a silly question, but I am trying this thing and stuck since many days. Any help would be much appreciated.

I guess.. if you provide more information, people here could help you! For example, actual commands and error messages. And how did you create your master branch and main branch. And so on..

@meet97

This comment has been minimized.

Copy link

@meet97 meet97 commented May 18, 2021

It worked for me
Thanks

@rickybell

This comment has been minimized.

Copy link

@rickybell rickybell commented May 23, 2021

Good work man.

@j-saurabh

This comment has been minimized.

Copy link

@j-saurabh j-saurabh commented May 24, 2021

I got the solution. I was trying to push to a project which had no link with each other. That is I had a local project and I made an empty repository in github, I should have cloned the repo, moved the files in that cloned repo in my local directory and then tried to push.
Now it is working fine. Thank you!

@vishnu92karthik

This comment has been minimized.

Copy link

@vishnu92karthik vishnu92karthik commented May 26, 2021

Thank you, Worked for me.

@BaseMax

This comment has been minimized.

Copy link

@BaseMax BaseMax commented Jun 4, 2021

Change ##2. Initialize the local directory as a Git repository. to ## 2. Initialize the local directory as a Git repository.

@dheerajrp

This comment has been minimized.

Copy link

@dheerajrp dheerajrp commented Jun 6, 2021

Thanks. Worked for me

@gitanupam

This comment has been minimized.

Copy link

@gitanupam gitanupam commented Jul 17, 2021

Thanks. Straightforward

@HaleemaEssa

This comment has been minimized.

Copy link

@HaleemaEssa HaleemaEssa commented Jul 25, 2021

Thanks. Worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment