How to add all empty folders on git from local - github

How to add all empty folders on github from local
To add files we generaly use git add folder/subfolder/file.txt
but I want on folder like git add folder/subfolder/subfolder-2

You can't add an empty folder to git. Some people opt to create a .gitignore or a .gitkeep file inside the directory.

Related

Where is the .github folder in the project repository?

I want to add a few config files to .github folder but I can't seem to find it in my repository. I do see the .git and .gitignore files. Where can I find this .github folder, Is it added by git or should I create it?
There isn't one unless you create it (and if you do, you should create it in the root directory for the repository).

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 to add an empty folder inside an already existing repository? Github [duplicate]

This question already has answers here:
How do I add an empty directory to a Git repository?
(37 answers)
Closed 2 years ago.
In GitHub, I already have an Automata repository with 1 project in it. I just want to add more projects in this repository. I wish to create different folders inside the Automata repository so I can better organize my projects. In other words, my question is "how to add a folder inside a repository?"
An empty directory cannot be part of the git versioning system. But you can use a little workaround.
You can add a .gitignore inside your empty directory. Add these lines:
#Ignore everything
*
#dont ignore this file
!.gitignore
The * will assure that no files in this directory will be tracked. However, as you probably want to add files later, you shouldn't put the star in. Therefore your .gitignore can be empty. You can add real files to ignore later, as your project grows.
To create the .gitignore type the following in your console:
$ mkdir $foldername
$ touch .gitignore
$ git add foldername/.gitignore
$ git commit -m 'added placeholder folder' $foldername
where you replace $foldername with the desired name of your folder.
Now you have a folder which is not completely empty, but only has one hidden file.
Github doesn't allow empty folders. You can make a folder and add a placeholder file to it and push that to your repository. That's the only way you would be able to create a new folder in your GitHub repo. You can't create a folder and then add files to it on GitHub, but rather the creation of folder must happen with a file inside that folder.
You can either push the folder through git commands. There's another option to directly drag and drop folders from your system to your GitHub repository.
To directly add a folder from the GitHub website, click on Create New File. Type in name of folder you want to create, add the file and Commit new file to add it. You can refer the below gif -

How to make subfolders repository in Github

I've been using this folder structure where I would have one main .git folder and then have subfolders inside which doesn't have .git folder.
So as example :
Main Folder
Subfolder
Subfolder
Subfolder
Now what I want to do is, I would like to extract some of those subfolders and make them separate repositories with their histories. Which means subfolders will become a main folder as a repository. Any idea how?
The official documentation use git filter-branch.
But that or BFG are obsolete.
Use the new tool git filter-repo (directly in your regular local repository, although a backup is always a good idea before those kind of filtering)
Use a path shorcut:
git filter-repo --subdirectory-filter Subfolder1
Only look at history that touches the given subdirectory and treat that directory as the project root.
Equivalent to using --path / --path-rename /:

How to push empty folder to AzureDevops through visual studio

I tried few times and failed to push empty folder, any way to push empty folder to azdo from VS.
For this issue, in Git, you cannot commit empty folders, because Git does not actually save folders, only files. You'll have to create some placeholder file inside those directories if you actually have no committable content.
You can refer to this How can I add an empty directory to a Git repository? and this official document.
You can add .gitkeep file inside this directory.