I am stuck at step 2 of the Learning Lab course github-upload.
I have to create a .gitignore file in my local environment. I can use a template or create my own.
What does "local environment" mean? I am working on a Mac. Do I have to use the Terminal and navigate first to my repository? If yes, how can I do that?
On GitHub help it says:
I am not very familiar with using the Terminal. How can I navigate to the location of my Git repository?
Many thanks for your help!
Solved! Solved! Go to Solution.
I am sorry this is not familiar to you. I will try and help.
Yes, your local environment is meant to mean your desktop computer or laptop. These days it could be a workstation in the cloud. It is simply a system with either windows, mac osx, or linux that can run git.
You would enter command line commands from a terminal session on this system. In mac osx terminal is in utilities under applications. In linux it is usually on the gui. I am not familiar with windows by I know some people install putty.
Then you must install git if it is not there. Installation will vary by machin OS type. You can google instructions for your system.
Once git is there, you use git commands to clone, add, commit, status, pull, push, etc. There are git cheat sheets on the internets as well.
I recommend that you look for an introduction to github and git learning lab as a starter, and get familiar with that first.
Please let us know if you have further troubles,
Hopefully I can help. Local environment basically means the machine you are working on that has your project folder. So in your case your Mac, you can create the .gitignore file manaually with any text editer, and save this in your project folder.
Or if you wanted to try in Terminal you would need to do the following:
your-machine-name:~ username$ cd Path/To/My/Project/
your-machine-name:~ username$ cd Path/To/My/Project/
You are now in your project folder where if you now use "touch .gitignore" this will create the file .gitignore which will probably be hidden if you try and look for it in the Finder.
You can check if its there by using Terminal, or if you are using a text editor like atom you should be able to see this file in your projects tree
From here you can modify the .gitignore in a text editer or in Terminal (using nano for example).
Hope that helps :) good luck
I forgot to mention if you were creating manually you might find when you save the file it might disappear due to the . at the start. In OSX these files are usually hidden.
Thanks for giving me support! I really appreciate your explanation.
So, when I create a new repository on my GitHub, this folder is going to be stored on my local computer? I thought it will be stored somewhere in the GitHub cloud, on the GitHub servers?
That's my question: I don't now, where GitHub stores my repositories on my computer. I tried to search for keywords like "github" or "repositories" in the Finder of my Mac, but couldn't find the folder...do you know where GitHub stores files on a computer by default? How is it on your computer? I couldn't find a path in my user's folder either...:-( Thanks for further advice! :-)
No problem @aurumpurum, it can be a bit confusing to get started understanding Git and Github :)
If you create a repository on Github, nothing is created on your local computer. its it just living on Github.
If you want to create a copy of the repo from Github to your machine you can do this a few ways.
Are you using Github Desktop? If so you can clone a repository using that. If I remember right using the Github Desktop will let you know if changes have been made on the repository on Github... its been a while since ive done it that way though. It might be that you can just click the Fetch Origin button, which is like saying "Go get me the most recent version of this repo".
Or you can copy a repo from the Github site, you can download it using the Clone or Download button. However, doing this will not mean your local copy will be kept up to date with and changed made directly on Github and vice versa. it is just a copy.
Let me give you a couple of examples of my own Github (and git) workflow.
Firstly git : if you didnt know already, git is a thing in its own right and Github is like a place that uses understands and uses git. you can have git on your machine, its not in anyway linked to Github unless you make the link between your local repo and a remote repo on Github.
I have git installed locally (although ive been using Github for longer than I've been using git on my machine!), and I feel it helped me understand what it is vs what Github is. I also use Atom as my text editor as this had git and github functionality built in.
So if you havent already, you might want to look into installing git on your local machine. Its not a requirement though. You can check if you have git installed by typing the following into Terminal
and after a short moment you should get an output similar to the line below.
git version 2.21.0 (Apple Git-122)
If not, and you get something like "git command not recognised" then you havent git on your machine. No worries though.
Anyway. an example workflow might be this:
git remote add origin https://github.com/user/repo.git
With me so far?
Example 2: You have your remote repo, but nothing local, no project folder and no git installed.
If you have not git installed then you can clone the repo from github using the button mentioned before (This will be more or less an empty folder if you havent any code in there, else it will be full of folders and documents or whatever is currently in the repo on Github).
Now if you change any of this code (in the copy you have now downloaded), in order to update it in the repository on github you could manually edit the files, maually on there and commit them, but its probably not the best method to be honest. Or you could use the Github desktop app and update the repo from that.
Either way, a github repo is like a public or private copy of a folder. You might have a copy on your machine but Github wont do this for you if you are just creating a repo on there, you will have to copy it one way or other yourself.
I hope thats not far too much information to take in, sorry if it is. Stick with it though, once you start understanding the basics its a fantastic tool!
Hey @Crammers ,
thanks a lot. It's a lot of information to take, but I really appreciate your effort to help me out! I will read your full post tomorrow.
But let us stay with my initial problem and question: I just want to store a .gitignore file in an existing repository, that I have on GitHub. As you know, I am doing the course "Uploading your project to GitHub" that is available at the Learning Lab. So I have just ran into problems with the following task:
Following the indicated links, I reach a help site: https://help.github.com/en/articles/ignoring-files
I just cannot follow the step-by-step instructions to create a local .gitignore:
I just don't know how to find my location of my Git repository in the Terminal as stated in step 1 above.
Does that mean, that I have to create a local copy first? Or can I create a .gitignore file on the Web Applicaton of GitHub under my repository?
Just to let you know I have installed Git, it's version 2.17.2:
I do have GitHub Desktop. But I haven't used it yet, because I first want to finish some basic courses.
I really believe that it's a very powerful application and I want to stick with it. But as you said, at the beginning it's overwhelming because of the huge amount of information to process in my brain :-) Cheers!
Sure, in the previous issue it asks where is your project, so its asuming you have a folder with a project either already on your machine or somewhere else. If this isnt the case then this will be why the next step doesnt make sense.
It would be best to create a folder somewhere on your machine, the desktop for example, and this will be your dummy project folder for this exercise, then you can create the .gitignore in there. Otherwise you can create a .gitignore directly in a repository on Github. Click the button Create New File and name it .gitignore
Anything you list inside this file will be ignored by git.
Commit it and thats it.
In step 3 you will be asked to go though the steps to upload the project so i would say creating the folder on your machine and making the .gitignore in there the better option
Hope that helps :)
Many thanks @Crammers. Your advice has helped me a lot to better understand the workflow. Really appreciate your support! I will continue the course tomorrow :-) keep in touch!