-
Notifications
You must be signed in to change notification settings - Fork 130
Newbie tip: To git init or not to git init, that is the question #564
Comments
Please provide a link to where the instructions you want to improve are located. |
Here are the links from github Help which describes how to create a local clone: This page is helpful, but it does not warn users that this should be directory where you have not already run git init. I posted this comment to your website after reviewing the Readme file in your public repository since I thought a new git and github user might find it helpful. However, if I have misunderstood the purpose of your repository, I apologize. I do not plan to post again. Best regards, Please provide a link to where the instructions you want to improve are located. — |
I don't understand, |
Yes, you are correct. In fact, a git init prior to git clone will produce an error. But I did not understand that. I was following other online instructions for setting up a repository which all include the git init step. Therefore, in preparation to clone the repository residing on github to my local system, I also did a git init in the local repository directory. Then the git clone command produced errors. I was confused by this. That was the whole point of my post, explainging that one should not git init in a directory where one plans to clone another repository. On the otherhand, if you plan to bring the repository residing on github down to your local system using git pull, you do need to have previously done git init. To new users, and I stress the fact that this is an issue which will primarily affect new users, this is something which should be explained. For users to have confidence in a new and quite different type of source control software, like git, explaining what is going on and why, is important. When things work as expected, it builds trust. Errors produce doubt and fear that something fundamental beyond one's understand is not working. If it is OK, I will add another post describing the different behavior of git pull to complete and better describe the point I was trying to make. ----- Original Message ----- I don't understand, git clone does not require git init. — |
Just one more clarification with respect to the initialization of a local empty git repository (i.e. directory) from a remote source. The correct command here is "git clone". It is a complete copy of another repository, including the .git directory. That is why you do not do a "git init "in that empty repository since then it will no longer be empty. Indeed, running "git clone" in a directory which has a .git dir produces an error. Another way to initialize a local repository with the contents of a remote repository is to run "git pull." In this case however, you do need to run git init first because "git pull" is actually going to merge the remote repository into your existing repository. If your repository contains no other files or subdirs besides the .git directory created by "git init", then it will essentially behave as if you did a "git clone". Likewise, if your local repository contains more objects than the .git subdirectory created with "git init", then "git pull" will merge the two repositories. There is obviously much, much more to learn about git. This is just step 1. |
Permission denied |
This is a tip for newbies to git and github. When I first started using git on my local machine, I followed a lot of how tos which said the first thing you did to create a repository was to cd to your repo directory in a shell, and call
Now, I wanted to try out more git features in a sandbox environment on my own machine instead of immediately jumping to a remote server like github. In other words, I wanted to test out the commands push, pull, clone, fetch, etc. somewhere local so I could simulate working with a remote storage location. In my case the somewhere local was just another drive.
I found these directions helpful in creating a "remote" shared repository on my D drive (I confess to being a Windows developer).
http://www.gitguys.com/topics/creating-a-shared-repository-users-sharing-the-repository/
Finally, I was ready to try out github. Now here is the golden nugget for a newbie to understand. After you push your repository to your github account location, and you are ready to have another user clone it, or you want to clone it in another directory to test out some stuff, the you DO NOT RUN the git init command since git clone brings down all those git files too.
I wish the github step by step mentioned this!
The text was updated successfully, but these errors were encountered: