-2

I started working on git and github recently and whenever I push files from git to github, it just pushes them into the repository right away, but I want to first of all, create a folder in my repository from git if it's possible and then push those files into that folder. Is it possible?

8
  • 1
    What's a "GitHub folder"? Commented Jul 18, 2021 at 7:43
  • How are you "pushing files"? Git can only push commits. Commented Jul 18, 2021 at 7:44
  • A github folder would be a folder that is created inside the repository, is it not? :D Commented Jul 18, 2021 at 7:45
  • 2
    Maybe you're thinking of branches? You can have directories within your repo just fine, but that's up to you not git/GitHub. Commented Jul 18, 2021 at 7:53
  • 1
    Does this answer your question? Creating folders inside a GitHub repository without using Git Commented Jul 18, 2021 at 8:02

3 Answers 3

1

You can only push commits, where files contain. And this files can be everywhere, also in a folder. So it is possible.

To have a folder in your remote repository, you must create a folder on your local repository (on your computer). As example you can create a folder as follow:

mkdir myFolder

Then navigate to this folder and create a file

cd myFolder
touch myFile.txt

(You can create this also on the Desktop of your computer instead of terminal/console). Now you are able, to push your folder with the file to your remote GitHub repository with committing and pushing

git add .
git commit - m "add new folder with file"
gut push

Now you have your desired folder in the remote repository.

Little note: You don‘t push files from Git to GitHub, you push commits, where files contain, from your local repository to the remote repository, where in your case is GitHub. I think you are still missing some basic git knowledge. Here a link as reference to read and learn more of Git and its rules: https://git-scm.com/book/en/v2

EDIT:

The question wasn‘t clear for me. After the comments, it is clearer, thst you want to create the folder IN GITHUB in your repository. For this look at this question: Creating folders inside a GitHub Repository without using Git

After creating this folder, you must git pull that you become this folder also on your local repository!

But I see no reason to create a folder in GitHub repository. That‘s actually not in the sense of git…

Sign up to request clarification or add additional context in comments.

Comments

-1

you can use the branches if you need to do something like archiving .| Also after that you can merge them into the master branch

Comments

-1

follow this steps:

  1. Create folder
  2. Create files inside folder
  3. git add .
  4. git commit -m "add your message"
  5. git push

2 Comments

I know about that, I'm asking if I could create the folder directly from git and not github and then push files in the folder from git
The folder is not created from GitHub in this response. I don't understand your question/comment. A folder you see on GitHub is necessarily a folder you'll see on your local repository as well.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.