55

I have been working on my local on a web app and I was ask to push it to an empty(only read me file on it) private repo created just for this project. I'm new to git and I'm having trouble doing so.

Can someone tell me what am I doing wrong?

I first navigate to the main folder of the app in my local using command line and initialize git. After, I try cloning the remote repo with:

git clone git://github.com/somename/Web-App.git

but I get the error:

Cloning into 'Web-App'... fatal: remote error: Repository not found.

I know the repo is there.. Do I actually need to clone or pull from that remote first or is there a way to just push to that repo.

Again, all I'm trying to do is to get the files that I have in my local pushed to a specific repo that I was given access to.

I will really appreciate any help.

e.doroskevic
  • 2,129
  • 18
  • 25
irm
  • 4,073
  • 6
  • 28
  • 32

6 Answers6

61

Let us say 'yourWebApp' is the folder you have your local web app. Change it to the directory

cd 'yourWebApp'

Init git in the folder

git init

Now add your github url as a remote

git remote add origin git://github.com/somename/Web-App.git

Here origin is the short name for your url

Now pull the read me file from the github repo

 git pull origin master

Now push your web app to the github repository

git push origin master

Here it is assumed that you are in your master, the default branch

Here pulling your readme files is necessary to merge the readme file with your local work. If your github repository is empty, you can skip the pull and directly push to your github repository.

On the other hand, if you want to use clone, there is no need to init as clone automatically sets up git in the directory. clone also sets your remote git url. In that case, your workflow should be

 git clone https://github.com/path/to/your/repo
 make some changes
 git add your changes
 git commit your changes
 git push
Matt C.
  • 2,330
  • 3
  • 22
  • 26
palerdot
  • 7,416
  • 5
  • 41
  • 47
  • 4
    Thanks for helping me. I'm fallowing the steps and I get an error when I do: git pull origin master fatal: remote error: Repository not found. – irm Sep 17 '13 at 05:58
  • In that case your repository name (or path) is not right. Enter your github repo link in your browser and see if it points to the right git repository (Remove the git:// when typing your url in the browser). – palerdot Sep 17 '13 at 05:59
  • I entered the link on browser and it does take me to the repo I want to push to. Does the folder where I have the app locally need to match the name of the repo? I didn't create the repo I'm trying to push to, I just have permission to push to this private repo. If that helps. – irm Sep 17 '13 at 06:06
  • Is your github credentials accepted without any problem ? I have not worked with private repos; so I'm not sure about errors originating from private repo access. Try these steps in the github help https://help.github.com/articles/error-repository-not-found – palerdot Sep 17 '13 at 06:11
  • 4
    Thanks for staying with me. It didn't ask me for any creadentials. After command: git remote add origin git://github.com/.../Web-App.git it just takes me to next line with no errors – irm Sep 17 '13 at 06:14
  • Type `git remote -v` and see what is shows. Alternatively, use `git fetch origin master` instead of pull, and see if it works. If that works, you have to manually merge the readme file with your local work using `git merge origin/master` – palerdot Sep 17 '13 at 06:23
  • 3
    After git remote -v it outputs the right repo. And if I do: git push origin master fatal: remote error: You can't push to git://github.com/name/Web-App.git Use https: //github.com/name/Web-App.git – irm Sep 17 '13 at 06:29
  • So I repeat: add origin git://github.com/somename/Web-App.git using https instead but I get:fatal: remote origin already exists. – irm Sep 17 '13 at 06:31
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/37496/discussion-between-palerdot-and-irm) – palerdot Sep 17 '13 at 06:31
  • 2
    Did this ever get resolved? I'm running into a similar issue where I can branch locally and push the branch to my remote, but cannot with a private repo. – The Stupid Engineer Feb 28 '17 at 13:55
  • @TheStupidEngineer the issue was resolved. It was some simple problem not related to private repos. If you are having problem with private repos, most probably you do not have access to push – palerdot Mar 01 '17 at 08:14
  • Have the same issue, Im the owner, but, im not able to push – EdwinCab Apr 26 '20 at 14:22
  • what does the error say? do you get any error information in the command line? – palerdot Apr 26 '20 at 14:39
  • What I did to get it working was, while adding a remote repo using : git remote add origin https://github.com//.git i added my credentials as : https://username:password@github.com//.git and it worked just fine ! – TheNoobDeveloper0299 May 27 '20 at 04:32
  • Wouldn't he need to add a token for accessing the private repo? – Cybernetic Mar 18 '22 at 23:12
  • This worked after I added `https` to my URL: `https:/git://github.com/somename/Web-App.git` – Jeff Bezos Mar 30 '22 at 15:33
  • Also, make sure you use `main` instead of `master`: `git push origin main` – Jeff Bezos Mar 30 '22 at 15:33
22

I was facing the same problem. I was able to solve this by removing old credentials from windows.

  1. Open Control Panel from the Start menu
  2. Go to User Accounts -> Credential Manager -> Manage Windows Credentials
  3. Delete any credentials related to Git or GitHub

Once I did this, it started working again.

Venkataraman R
  • 12,181
  • 2
  • 31
  • 58
simmmplyAmit
  • 329
  • 2
  • 3
5

To push to a private repository, you probably want to fork it, push your changes to your copy (which will stay private), and then create a pull request. When I tried to push directly to a private repository, I got the puzzling "remote: Repository not found. fatal" message, even though I could pull just fine.

Ken Shirriff
  • 1,654
  • 16
  • 20
1

I was forgetting to put https before my URL:

git remote -v # URL doesn't have https
git remote remove origin # remove old URL
git remote add origin https://github.com/user-name/project-name.git # add new URL w/ https
git push -u origin main # try again

If you don't remove the old URL, you'll get error: remote origin already exists.

Jeff Bezos
  • 1,929
  • 13
  • 23
0

git clone is a little bit overkill for this purpose.

The mechanism that git provides to deal with other servers is fittingly called remote. This is typically automatically set up when you clone, explaining why that was your instinct.

Documentation can be found here:

http://git-scm.com/book/en/Git-Basics-Working-with-Remotes

Some summary commands:

git remote add [remote-name] [branch-name]

git fetch [remote-name]

git push [remote-name] [branch-name]

In addition, you might consider setting up tracking branches, which will eliminate the need to qualify the remote name each time you type a command. Documentation for that use case is here.

http://git-scm.com/book/en/Git-Branching-Remote-Branches

Usually, if you clone a repository, git executes git checkout -b master [remotename]/master

Your tracking branch doesn't have to be master though.

Hope this helps.

WyssMan
  • 66
  • 4
0

In only two steps:

git remote add origin 'your_url_name'
git push -u origin master
Java bee
  • 2,522
  • 1
  • 12
  • 25