GitHub set folder structure of master.zip - github

When I download the master.zip of my project on GitHub I get a .zip file containing a folder named something-master that contains all the source code.
Is it possible to download the master.zip in a way that the whole sourcecode is in the "root" of the zip without subfolder?

No, but if you download the tar.gz (as file 'master') instead of the zip, you can extract it in any folder you want without the top folder:
tar xvf master -C yourFolder --strip-components 1

something is the name of the repository.
As the zip file is built by GitHub, you cannot customize the way it's done just clicking on the download button.
Anyhow you can always unzip everything in the same directory (discarding any subfolder) running this command:
unzip -j something-master.zip
from terminal/console

#VonC's answer did the trick. All together:
Download the repo via tar file:
curl -L -o reponame.tar.gz https://github.com/username/reponame/archive/master.tar.gz
Extract without the top directory to YourTargetDir:
tar xvf reponame.tar.gz -C YourTargetDir --strip-components 1

Related

Wget command does not download the github repository, "Not a directory" error?

I need to download the contents of this page: https://github.com/kata-containers/packaging/tree/master/kernel
Unfortunately, :
wget https://github.com/kata-containers/packaging/tree/master/kernel
is not working. It downloads something called 'kernel' and then when I do 'cd kernel' I get "-bash: cd: kernel: Not a directory."
Why is wget not downloading the contents of the directory?
"kernel" is the HTML file for the page you are looking at. You can download the entire repo at https://github.com/kata-containers/packaging/archive/master.zip and peruse the kernel subfolder.

Tell github to use custom file to display as the project's README

Is there a way to tell github that the project's readme file is not README.md but <project-name>.md?
The GitHub documentation states that GitHub will specifically display the contents of a file named README.md that is present in the root of your project or in the .github or docs subdirectories.
There doesn't appear to be an alternative here, though you could make your README.md file simply contain a link to another page of your choice.
Create a directory called .github and add a README.md there, but not an ordinary file. Use a symlink to the file you want to be the readme.
$ mkdir .github
$ cd .github
$ ln -s ../project-name.md ./README.md
$ git add README.md

Basic Github Repo Creation

I just created my first Github Repo through the Github Bash on Windows 10.
I ran:
$ mkdir Projects
$ mkdir Projects/DataScientistsToolbox
$ mkdir Projects/DataScientistsToolbox/sample
$ cd Projects/DataScientistsToolbox/sample
$ git init
Initialised empty Git repository in /home/osboxes/Projects/DataScientistsToolbox/sample/.git/
$ ls -la
I am really struggling with understanding this code. So I created three directories: projects, datascientiststoolbox, and sample.
What does the cd command on my code do?
Does the git init code run the creation?
What does the ls -la do?
Lastly, I can't seem to find where the repo is saved on my computer, is it located on the desktop or in a special spot?
Thank you, sorry about the large amount of questions.
The cd command lets you change your working directory.
Yes, git init creates (initalizes) a new repository on your machine in your current working directory.
ls displays all files and directories in the current working directory. -la changes the way they are printed.
pwd makes your machine print the working directory. Use it to find out where your repository was created.
Read here about how to create a GitHub Repository. And this is a list of basic unix commands - it may help you to get started with unix systems.
You created only one repository with git init. cd stands for change directory, it's like when you double-click a folder to open it.
So basically your repo is in Projects/DataScientistsToolbox/sample.
ls is used for listing all files in the current directory you're in. -la are flags for different styles of displaying (try running just ls).
Also, all these commands have nothing to do with GitHub. They're a part of git.

WGET Download specific folders under an apache directory

I want to download some folders under the same directories by using wget, here is the structure of the apache directory.
example.com/main/eschool/PhotoAlbum/Album/2008-10-13-citieneducationcenter/
example.com/main/eschool/PhotoAlbum/Album/2009-11-12-snfkdgjndfk/
example.com/main/eschool/PhotoAlbum/Album/2012-10-9-dsngosdgndfk/
...
It is found that there is a pattern:
example.com/main/eschool/PhotoAlbum/Album/20*, is it possible to download all those folders?
If you want to download everything under example.com/main/eschool/PhotoAlbum/Album/, but not above it, you can use the --recursive and --no-parent options:
wget --no-parent --recursive http://example.com/main/eschool/PhotoAlbum/Album/
That will download everything below Album directory. If you want to limit how deep wget dives into the subdirectories, you can specify the --level option:
wget --no-parent --recursive --level=3 http://example.com/main/eschool/PhotoAlbum/Album/
That will drill down up to 3 subdirectories below Album.
However, neither of these methods filter by name – they will blindly download everything in a directory, and its subdirectories. If you want more control (e.g. to only download albums beginning with 20*), you'll have to use a shell script, or a scripting language.

How can I modify the folder name inside the zip downloaded from my github repo?

The folder name of the zip downloaded from github is like %repository-name%-master, but I need that folder just as %repository-name%
Can this be done?
You cannot modify the name of the root directory contained in an archive from github.
Even when you download master:
wget https://github.com/user/repo/tarball/master
You will get a file named 'master', but:
tar xpvf master
The tar xpvf will give you a repo-xxxx directory.
I usually follow with:
mv repo-* repo