Why does GitHub create a .gitignore folder? bug or feature? - github

I create a new repository (empty) using the GitHub webclient and then add a .gitignore using the Getting Started screen and choose a template.
When I commit the file, it creates the .gitignore file inside a .gitignore folder.
reponame/.gitignore/.gitignore
But when I set the gitignore with a template on the "Create a new repository" screen it will be just the .gitignore file in the root folder.
reponame/.gitignore
I'm relatively new to the gitignore concept so I would like to know, is this a bug or a feature I'm not aware of?

Related

Why is Github desktop creating a new folder rather than using the one I specified when creating a new local repo?

I am looking to do something I thought was pretty simple... I have an existing folder (with project files) on my desktop that I would like have tracked by Github desktop for purposes of source/version control. It seems straightforward... I go to github desktop, select that I'd like to create a new repository, and point it at the folder on the desktop. Here is what I expect to happen:
Desktop
Project folder
Project files
(hidden) .git folder
(hidden) .gitattributes
Instead, this is what I get:
Desktop
Project folder
Project files
New folder with specified git repo name
(hidden) .git folder
(hidden) .gitattributes
I am not sure why this is happening and it is very frustrating. It looks to me like I have only two options here:
Cut and paste Project files into New folder with specified git repo name
Cut and paste .git folder and .gitattributes out of New folder with specified git repo name and into Project folder, delete New folder with specified git repo name, remove the new repo in Github Desktop when it says it can't find it, and "Add Existing repo" in Github Desktop and point it at Project folder.
Both of these approaches sort of feel like hacks and I am not sure what consequences, if any, may negatively impact my version control intention as a result. Is this a common problem? What should I do?
I wouldn't use github desktop to make your repository. If you don't have it already try installing git bash, a command line interface, and initialize git from there.
Find your existing folder and move to it using cd <folder name here> if you go into the wrong place use cd .. to move out/back one folder
When in your folder use git init to initialize git(the version control software)
Open GitHub Desktop once again and hit "add" then "add existing repository" finally "choose" and find your file in your file explorer
When you go to "Create a new repository":
Name: New folder with specified git repo name
Local Path: Desktop (ie one level up from Project files)
This will create the .git and .gitattributes in your existing folder without affecting the other files.
The Create a new repository dialogue seems to assume the name should be used as a new folder under the path you specify.
Note that if there are spaces in your name, it tries to replace them with hyphens.

Ignore files in a Project to a Fork in Github

I want to ignore some files from a project in Github, so they don't show on my fork.
ex: README.md in another language which I won't use/update, to not show on my project when I Fork it.
Is that possible?
Add that file or directory to your .gitignore file in the root directory and make sure to commit the file.

How do I use .gitignore in visual studio code?

So I know this might sound like a noob question but I'm rather inexperienced with GitHub. I want to add a gitignore file to my repository, but I am unable to do so and I don't know how. I want to make sure a file is gitignored My visual studio code is connected with my repository. So I am able to push and pull via visual code.
Greetings,
Parsa & Liyam
You may go to File > New File at the root of your git repository (same directory as where your .git hidden folder is in). Then add all the directories/file that you want to be ignored into that new file and save it as .gitignore. (You can save as a plaintext file and just name it .gitignore within VS Code.
Vscode 1.46 is adding some automated help in generating a .gitignore file when you publish to github. From v1.46 release notes:
Publish to Github: Generate .gitignore
It's now possible to generate a .gitignore file when publishing a
workspace to GitHub. When publishing a workspace to GitHub, you are
prompted to select which files to include in the repository.
You can press Ctrl+Shift+P on your Visual Studio Code and then search for gitignore. Click the add gitignore option then you are good to go.

ignoring the build folder in an eclipse project in git repo

I am using eclipse java as an editor and would like to use the .gitignore to exclude the build folder for the project. This is what I have currently written in my .gitignore. The syntax seems to be right; I used the git documentation but I may have interpreted it wrong.
#ignoring the files within the build folder
/build/
build/**
I'm using a brand new repo so I shouldn't have any problems with already logged files in the repo.
I am trying to get git to ignore the build folder in the project file using a .gitignore. The ignore file didn't work. What could be a solution?
The way the .gitignore is written, this file needs to be in the same subfolder as the build folder, the file being ignored.

Add new folder with files to github

Probably one simple question. I pushed my first project to github. I've done it with Eclipse with EGit plugin. I've clicked on a project, chose to push remote and uploaded it to git. There I have created readme file online so the structure looks like this:
Git
-- AppFolder
------srcFolder
------libsFolder
------resFolder
------etc etc
-- Readme.md
I have one other folder with screenshots of the app which I would like to have outside my app folder. Something like this:
Git
-- AppFolder
------srcFolder
------libsFolder
------resFolder
------etc etc
-- Readme.md
-- ScreenshotsFolder
------screenshot1
------screenshot2
------etc etc
How can I accomplish that? I don't want to put that folder with screenshots to AppFolder. Thank you.
Locally, just create the ScreenshotsFolder in the same directory level as AppsFolder and README.md.
Then, git add ScreenshotsFolder will add the folder and all of its content (really, all content that is not in your .gitignore file if you have one).
Next just git commit then git push remote_repo remote_branch (ex: git push origin master).
If you aren't doing this via the command line, I'm sure the EGit plugin has some option to add the ScreenshotsFolder and do a commit then push...haven't used EGit myself, though. The steps are the same either way, just a different interface.
Are the files intended to be committed? If not, you could just .gitignore that directory.
edit: if the files are meant to be committed, why can't you just add and commit them like normal, but in new directory?