0

Github Desktop is installed and running. I have downloaded Git LFS and am trying to sync my repository and large file to the Gitlab server. However, I am getting the following error and am unsure how to proceed.

Alexanders-MBP:large-repo alexander$ git commit -m "add simplified_2011.geojson"
[master (root-commit) af76f48] add simplified_2011.geojson
 2 files changed, 1 insertion(+)
 create mode 100644 .gitattributes
 create mode 100644 simplified_2011.geojson
Alexanders-MBP:large-repo alexander$ git lfs ls-files
f93b176e1d * simplified_2011.geojson
Alexanders-MBP:large-repo alexander$ git push origin master
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

It seems I have somehow skipped the following step

git clone git@gitlab.example.com:group/project.git

which is provided in the setup instructions

But when I try this, it also fails...

Alexanders-MBP:large-repo alexander$ git clone git@gitlab.example.com:group/project.git
Cloning into 'project'...
ssh: Could not resolve hostname gitlab.example.com: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

How can I fix this?

Scott Weldon
  • 9,673
  • 6
  • 48
  • 67
iskandarblue
  • 7,208
  • 15
  • 60
  • 130

2 Answers2

0

It seems I have somehow skipped the following step

git clone git@gitlab.example.com:group/project.git

Since you skipped that step, you don't have a remote set up yet. Thus git push origin master makes no sense, because origin is not defined.

To fix this, add a remote:

git remote add origin git@gitlab.example.com:group/project.git

Also, when you see example.com in a URL, that is an indication that you need to customize the URL to match your specific setup. So if your server is called gitlab.thedarkside.com, your group is called MyGroup and your project is called large-repo, then your command would look like this:

git remote add origin git@gitlab.thedarkside.com:MyGroup/large-repo.git

(And you'll need to create the repo in GitLab if you haven't already.)


You could also re-clone the repo (after fixing the URL as mentioned), but as I've said before, you shouldn't ever need to delete and re-clone a repo; there is usually a way to fix any existing issues you have. (And you would have to redo the work in your existing commit.)

Scott Weldon
  • 9,673
  • 6
  • 48
  • 67
-1

Remove Git. Start over and do things in the correct order. Sorry, but that IS the easiest way to get it fixed. Do it again and do it right.

Edit:

Why the negative vote?

It seems I have somehow skipped the following step git clone git@gitlab.example.com:group/project.git

If a step is missed in the installation, it's going to give out errors, and removing GIT and installing it again following the instructions in the official git setup instruction is the easiest solution.

The second error, ssh: Could not resolve hostname gitlab.example.com is, however, an error that says your git host is setup incorrectly. If you're trying to actually use gitlab.example.com, it's not going to work, since that is not an actual git repo. But I assume you're using a different host?

Jerri Kangasniemi
  • 633
  • 1
  • 9
  • 23
  • This answer is incorrect. You should not even need to delete the **repo** and re-clone, and it's really overkill to reinstall Git! The correct answer is to add a remote, as I said in [my answer](//stackoverflow.com/a/40391704/2747593). **Flaggers / reviewers:** [For incorrect answers such as this one, downvote, don't delete!](//meta.stackoverflow.com/q/287563/2747593) – Scott Weldon Nov 02 '16 at 23:54
  • In addition, please note that Git is not an acronym, so the correct capitalization is "Git", not "GIT". – Scott Weldon Nov 02 '16 at 23:55
  • From your answer: "Also, when you see example.com in a URL, that is an indication that you need to customize the URL to match your specific setup.". From my answer: "an error that says your git host is setup incorrectly. If you're trying to actually use gitlab.example.com, it's not going to work". I know what's wrong as well, but seeing how it's obviously a first-time setup, telling the person to [RTFM](https://nerddrivel.files.wordpress.com/2013/05/moses-rtfm.jpg) and follow the instructions is as correct an answer as any. SO is not "Teach me service" and there are Git guides to follow. – Jerri Kangasniemi Nov 03 '16 at 09:56
  • Yes, that part is correct, but that wasn't the main issue the OP had. If you want to tell the OP to start over, that's fine, but "starting over" (or "RTFM and follow the instructions") here means re-cloning the repo, **not** reinstalling Git. If you think the OP is treating SO as a "teach me service", then [instead of answering you should flag the question](//meta.stackoverflow.com/q/276572/2747593) as too broad (but IMHO this question is specific enough to remain open). [Note also that "RTFM" is not a valid close reason.](//meta.stackoverflow.com/a/253484/2747593) – Scott Weldon Nov 03 '16 at 17:16
  • Fair enough, then. Just ticks me off when questions pop up that shows no effort into researching the error oneself, just a "hmm. Not working, better ask someone". I wanted to only drop a LMGTFY link, but I do know that is against any good practice and against SO policy. – Jerri Kangasniemi Nov 04 '16 at 07:58