How to create folder in github repository?

无人久伴 提交于 2019-11-27 16:37:16
moopet

git doesn't store empty folders. Just make sure there's a file in the folder like doc/foo.txt and run git add doc or git add doc/foo.txt and the folder will be added to your local repo once you've committed (and appear on github once you've pushed it)

You cannot create an empty folder and then add files to that folder, but rather creation of a folder must happen together with adding of at least a single file. On github you can do it this way:

  • go to the folder inside which you want to create another folder
  • click on New file
  • on the text field for the file name, first write the folder name you want to create
  • then type /. This creates a folder
  • you can add more folders similarly
  • finally, give the new file a name, (eg. .gitkeep which is conventionally used to make git track otherwise empty folders; not a git feature though)
  • finally click Commit new file.

First you have to clone the repository to you local machine

git clone github_url local_directory

Then you can create local folders and files inside your local_directory, and add them to the repo using

git add file_path

You can also add everything using.

git add .

Note that git does not track empty folder. A work-around is to create a file inside the empty folder you want to track. I usually name that file empty but it can be whatever name you choose.

Finally, you commit and push back to github

git commit
git push

For more info on Git, checkout Pro Git book.

For the ones using the web browser. You can do the following:

  • Once in the master repository
  • Click on Create a new file.
  • In the name of file box at the top , Enter the name of your folder
  • Use / key after the name of the folder, This front slash creates the folder
  • You can see a new box appear next to the folder name where in you can type the name of your file.
  • In the commit new file box below you can type the description for your file.
  • Select the radio button Commit directly to the master branch.
  • Click on the Commit new file button
  • You will see the new directory will be created.

Create a new file, and then on the filename use slash. For example

Java/Helloworld.txt

Actually Github Does not create a Empty Folder.

For Example, to create a folder on C:\Users\Username\Documents\GitHub\Repository:

  • create a folder name docs

  • create a file name index.html under docs

  • open Github for desktop

    It will automatically sync and it will be there.

I hope it Helps.

Mohanraj

You just create the required folders in your local repository. For example you created app, config directories.

You may create new files under these folders.

For Git Rules :

  1. First we need to add the directory, files.
  2. Then commit those added files.

Git command to do commit :

  1. git add app/ config/
  2. git commit

Then give the commit message, then save the commit.

Then push to your remote repository, 1. git push origin remote

To add a new directory all you have to do is create a new folder on your local repository.Create a new folder ,add a file in it. Now go to your terminal and add it like you add the normal files on GIT.Push them into repository and check the status to make sure you have created a directory.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!