Lots of branches and empty folders


(Eduardo Gutierrez) #1

Here i have some doubts about use of git / github…

1 - Can i upload/download many branches at once ( ex: you began a repo locally, with master and then create bugfix and develop branches, then you create a github repo and link to it using remote) ,… then i want to upload all the things i have locally to github.
I also need to do the reverse, example you create some branches and commits in github and want to download to your machine ( not cloning). Some kind of git pull all

2 - Is there a way to clone or fork the whole wiki of a repo ? Get a copy of it in some way

3 - Git is unable to push/pull empty folders ? I create an empy folder for css for example, just to fill it in the progress of the project, but i cant till i have a file inside ?

Thanks in advance


(Joachim Francois) #2

Hi @ejgutierrez74,

  1. Sure you can, you just need to use a little command line Fu.
    for b in git branch -r | grep -v -- '->'; do git branch --track ${b##origin/} $b; done

I’m sure other ways to accomplish this exist as well.

  1. Unsure of what you’re trying to accomplish. Do you mean to extract just the wiki from a repo? If so you should be able do so by adding .wiki just behind the repository name

git clone git@github.com:ConsoleFriend/OneOfMyRepos.wiki.git

  1. Git in essence is:

a stupid content tracker
Quote: Paolo Perrota ‘How Git Works’

So in essence there’s no control on empty folders. If you do want to add one, there’s a few hacks out there that accomplish doing so. So far I’ve found adding an empty file called .gitkeep is doing the best trick in accomplishing this in a clean way.

Hope this helps!


(Eduardo Gutierrez) #3

Thanks for your help…

1 - Very pro id make a test i was asking at some git command line instruction…perhpas…

git push origin --all or --mirror… but havent tested and dont know if its polite or bad practice…

2 - Id try…i wanted to fork some wiki pages from projects or clone them

3 - Seems little silly, no to track an empty file… i have read about you answer here, but i thought there could be some improvements or new features that could leave as work with empty folders…

Thanks again


(Joachim Francois) #4

Hi @ejgutierrez74,

  1. The linked post from the Atlassian community is indeed also a valid way. Nice share. It all depends on what you’re looking for and what exactly you’re wanting to accomplish.

  2. Perfect, let me know if you were able to make it work. You should have no issues in achieving this.

  3. I agree with that. However that’s solely related to how git works.


(Jakub Narębski) #5

1 - Can i upload/download many branches at once […]

Yes, you can. Regarding uploading, the current default configuration that Git uses is to push a single branch, but you also can:

  1. Push all the local branches using --all option, e.g. git push origin --all
  2. Push all matching branches (i.e. the ones that you have pushed at least once, and that exist on the remote) with the : (colon) refspec, e.g. git push origin :

You can fetch all branches with git fetch.

3 - Git is unable to push/pull empty folders? I create an empy folder for css for example, just to fill it in the progress of the project, but i cant till i have a file inside?

This is Git limitation, which AFAIK stems from the fact that while repository uses hierarchical structure to represent directory hierarchy, the staging area (aka. the index) is flat.

One workaround is to create empty .gitkeep or empty .gitignore file inside said directory.


(Eduardo Gutierrez) #6

Thanks for your answer… one doubt if you get all branches from remote with git fetch… what about git pull ??
You only need to git pull or need git pull --all


(Jakub Narębski) #7

With the default configuration that git clone and git remote add sets up for the remote, both git fetch and git pull will get all branches, putting them as remote-tracking branches in the remotes namespace (for example master branch in the remote repository origin gets fetched as origin/master).

git pull is git fetch followed by integration of specific branch, usually with git merge.


(Vanessa) #8

Changing the topic to refer to the conversation