简体   繁体   中英

How I can move JavaDoc from master branch to gh-pages branch on GitHub using EGit and Eclipse?

I have a java project hosted on a GitHub. And I want to allow see JavaDoc HTML-page for this hosting. For this purpose I create gh-pahes branch.

How I can easy move/commit JavaDoc (that created into master branch) into gh-pages branch using EGit and Eclipse IDE? I regenerate JavaDoc often and want find way to easy commit new version JavaDoc to gh-pages but working into master branch.

This is not in Eclipse, but this is how I do the move in command line without a second clone of the repo. First I configure my javadoc plugin to generate the docs in the folder "apidocs" in my project directory using this in my pom.xml

<build>
  <plugins>
     ...
     <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>2.10.3</version>
        <configuration>
          <reportOutputDirectory>apidocs</reportOutputDirectory>
        </configuration>
      </plugin>
      ...

Then I add "apidocs" to my .gitignore in master. Then to make and move the javadocs, I do the following - starting in master:

mvn javadoc:javadoc
tar cfv apidocs.tar apidocs
git checkout gh-branches
tar xfv apidocs.tar
git commit -a
git push
rm apidocs.tar
git checkout master

The trick is that the tar file (which never ends up in the repo) does survive the switch between branches - whereas it seems as though the changes to apidocs files in the folder hierarchy vanish when I switch branches.

Nicely when I switch back to master - the apidocs folder is gone.

I suggest that you use a second clone of your repository with a checked out gh-pages branch. Then you can easily move and commit your generated files without switching between the master and the gh-pages branch.

I found not so good solution as I want, but it is works:

  1. Create gh-pages branch in a GitHub.
  2. Checkout this branch.
  3. Switch from gh-pages to master and generate javadoc .
  4. Commit javadocs .
  5. Switch from master to gh-pages branch.
  6. You can see that gh-pages branch includes javadoc folder.
  7. Just commit this folder into gh-pages .
  8. See how to update!

How to update:

  1. In master branch remove all javadoc directory and regenerate javadoc .
  2. Commit only the generated javadoc ! .
  3. Switch from master to gh-pages branch.
  4. Remove old javadoc and commit this changes!
  5. Right-click on you project and select Team -> Show in History .
  6. Found you commit with javadoc from master branch.
  7. Right-click on this commit and select Cherry Pick .

Thats is all! Now you commit from master branch copy to gh-pages branch!

I don't know WHY I need using special branch for access to my HTML docs in the GitHub?! Use Google Code is MORE useful!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM