Github Windows: working with the "master" and "gh-pages" branches

I have a painfully simple jQuery plugin that I wrote and posted on github. I use Github for Windows and the site itself for project management.

Unfortunately, if I try to include any .js or .css files that I downloaded there through Raw links, it does not work in my browser due to the MIME type being plain/text .

So, over the past couple of hours, I have been learning how to get a copy of files through github that people can connect to (including me). The first step, apparently, is to create a project page (gh-pages branch) ... which I understood.

However, all the material that I have found so far, either expects you to have a UNIX-based system, or some kind of console blende:

Examples: GitHub , https://stackoverflow.com/a/212960/

It should now be an easy way to just make these source files available for inclusion. I went through the automatic steps to create a “project page” and now I’m presented with another branch that claims to be located behind the “master” branch, but I don’t see what I should do next. It’s not even clear to me why on earth I need to make another branch. All this seems a lot more complicated than necessary.

So, to repeat:

  • I created an affiliate on Github (using a windows application and website)
  • I can manage this and update my files without incident
  • I cannot include .js and .css files using raw links
  • I want to include these files on the page
  • I would like to do this through Github for Windows or on the site itself

If anyone could help me get through this, I would appreciate it. Also, I would expect A LOT of others to be.

EDIT: Here is an example of a well-known Github project that has its files available through Github:

Select2 : http://ivaynberg.imtqy.com/select2/select2-3.4.2/select2.js

EDIT2: Well, conceptually, now I understand why I have to create a separate branch to share files - since the Github version control aspects are not intended to act like a CDN, the project page simply provides a public website on which you can host your files. So now the question arises: how to put files from the main branch to the gh-pages branch? I'm not worried about automating this or something right now, all I want is access to the directory structure, so I can put files there. I tried to synchronize and re-synchronize my branch with Github Windows, but it tells me that there is nothing to get from the gh-pages branch, even if it is "10 delayed". What's happening?

EDIT3: Added my own answer for what I came for (for now).

+4
source share
2 answers

As already mentioned, there is a lot of information for people who use the Git console software. However, I could not find any information on how to do this only through Github Windows. Well, here is the solution:

process:

  • Create the project page as described here: https://help.github.com/articles/creating-pages-with-the-automatic-generator

  • Unfortunately, they only have a console solution to get a local copy. So how does it all work on Github Windows ... (assumption: the project name is myproject , consisting of myproject.js and myproject.css)

  • Once the page has been created (takes a few minutes), open Github Windows.

  • On Github Windows, open the repository for the project. In the top line of the menu there is "synchronization", "wizard", "tools". Press "master" and go to the "gh-pages" branch - Example SO> .

  • When you do this, the C:\Users\YourName\Documents\GitHub\myproject folder will now display the files for the gh-pages branch. If you press "master" in Github Windows, this will change the folder structure to represent the "master" branch again. This is what confused me before; you cannot see the directory structure for both branches at the same time.

  • Select the "master" branch in Windows Gitub.

  • In Windows Explorer, copy myproject.js and myproject.css to a separate directory (for example, c:\temp ).

  • Return to Github Windows and select the "gh-pages" branch.

  • Go back to Windows Explorer and cut out the files placed in c:\temp and paste them into a directory, for example C:\Users\YourName\Documents\GitHub\myproject\myproject-1.0\

  • Go back to Github Windows and you will see "2 files to be committed." Enter a commit message and click Commit.

  • Then click "Sync."

  • Now you can include these files in your web pages using the URL, for example: http://yourname.imtqy.com/myproject/myproject-1.0/myproject.js

Obviously, this is a huge pain in the ass to do it this way if you plan on regularly updating the source files. Obviously, an automated approach would be ideal. For this, there is an answer to SO here, unfortunately, it includes UNIX-based scripts that I have zero knowledge of (and, frankly, lack of interest in learning exactly for this), If anyone comes up with a more efficient way to do using only GUI-based tools, I’m sure that myself and many others will be interested in hearing about it.

EDIT: This solution obviously usurps Github, intended to do something, for example, when I click on the "gh-pages" branch on the github website, it tells me that it "5 pushes forward and 11 captures the "leading branch", although they have the same files. So, again, if someone else has a better solution for this problem, I’m all ears.

+5
source

Git (hub) software for Windows is the hardest thing I've ever used (well, except for Windows itself). When I used Windows, I could hardly use anything at all with Git.

But, in any case, to answer your question, if you open the command line and enter

 git checkout -b gh-pages 

(if he complains about existing gh pages of the branch, remove -b .)

he must switch the branch. Then you can run notepad ++ or any text editor that you use ( you may need to do this from the terminal, I can’t remember ), add the desired file and then enter (in cmd):

 git add . 

This recursively adds all the files to the Git folder.

 git commit -m "Add file for easy user download" 

This adds a commit message.

 git remote add origin git@github.com :yourusername/yourrepository.git 

This adds the Github repository, so you can click on it

 git push origin gh-pages 

This pushes your changes to Github.

And you are all set!

You might want to read this in the Git branch.

+1
source

Source: https://habr.com/ru/post/1499515/


All Articles