DokuWiki

It's better when it's simple

User Tools

Site Tools


devel:git

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
devel:git [2016-01-24 18:49] Aleksandrdevel:git [2024-02-06 10:39] (current) – [How to use Git] Web links was checked and updated. Aleksandr
Line 3: Line 3:
 The [[:DokuWiki]] sources are managed through the [[http://git-scm.com/|Git]] version control system. Git is a free and open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency. The [[:DokuWiki]] sources are managed through the [[http://git-scm.com/|Git]] version control system. Git is a free and open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
  
-Git is **NOT** offered as optional version control backend for DokuWiki itself. Refer to closed (and not completed nor started) [[:bounties?&#version_control_with_branching]].+Git is **NOT** offered as optional version control backend for DokuWiki itself.
  
 ===== How to use Git ===== ===== How to use Git =====
Line 9: Line 9:
 Instead of repeating things that were said elsewhere I just want to give some pointers: Instead of repeating things that were said elsewhere I just want to give some pointers:
  
-  * [[http://git-scm.com/download|Download Git]] +  * [[https://git-scm.com/download|Download Git]] 
-  * [[http://git-scm.com/|Git Community]] +  * [[https://git-scm.com/|Git Community]] 
-  * [[http://schacon.github.com/git/user-manual.html|Git User Manual]]+  * [[https://schacon.github.io/git/user-manual.html|Git User Manual]]
   * [[http://contribute.jquery.org/commits-and-pull-requests/|Working with branches: Commits and Pull Requests]] (by jQuery Community)   * [[http://contribute.jquery.org/commits-and-pull-requests/|Working with branches: Commits and Pull Requests]] (by jQuery Community)
  
 There are also some good books about Git: There are also some good books about Git:
-  * [[http://progit.org/book/|Scott Chacon - Pro Git]] (ISBN 978-1-43021-833-3) -- You can read it online **for free** (CC licensed). Translations are also available (e.g. German). +  * [[https://git-scm.com/book/en|Scott Chacon - Pro Git]] (ISBN 978-1-43021-833-3) -- You can read it online **for free** (CC licensed). Translations are also available (e.g. [[https://git-scm.com/book/de|German]]). 
-  * [[http://www-cs-students.stanford.edu/~blynn/gitmagic/index.html|Ben Lynn - Git Magic]] (ISBN 978-1-45152-334-8) -- You can read it online **for free** (GPL licensed). Translations are also available (e.g. Spanish). +  * [[http://www-cs-students.stanford.edu/~blynn/gitmagic/|Ben Lynn - Git Magic]] (ISBN 978-1-45152-334-8) -- You can read it online **for free** (GPL licensed). Translations are also available (e.g. [[http://www-cs-students.stanford.edu/~blynn/gitmagic/intl/es/|Spanish]]). 
-  * [[http://www.pragprog.com/titles/tsgit/pragmatic-version-control-using-git|Travis Swicegood - Pragmatic Version Control Using Git]] (ISBN 978-1-93435-615-9)+  * [[https://pragprog.com/titles/tsgit/pragmatic-version-control-using-git/|Travis Swicegood - Pragmatic Version Control Using Git]] (ISBN 978-1-93435-615-9)
   * [[amazon>0596520123|Jon Loeliger - Version Control with Git]] (ISBN 978-0-59652-012-0)   * [[amazon>0596520123|Jon Loeliger - Version Control with Git]] (ISBN 978-0-59652-012-0)
  
Line 37: Line 37:
 To fetch the current development version of DokuWiki use the following command (This creates the directory **dokuwiki** for you): To fetch the current development version of DokuWiki use the following command (This creates the directory **dokuwiki** for you):
  
-  git clone git://github.com/splitbrain/dokuwiki.git+  git clone git://github.com/dokuwiki/dokuwiki.git
  
 To update an existing checkout use this command from within the DokuWiki directory: To update an existing checkout use this command from within the DokuWiki directory:
Line 63: Line 63:
   git format-patch origin/master   git format-patch origin/master
  
-This creates one (or more) numbered patch files that can be mailed manually to the [[:mailinglist]].+This creates one (or more) numbered patch files that can be mailed manually to the [[:mailinglist]]. However, this method results in extra manual work for the maintainers of DokuWiki, and makes it difficult to provide feedback on your contribution. So please continue to the section below, and try offering your changes as pull requests.  
 + 
  
 ==== Tips and Tricks ==== ==== Tips and Tricks ====
Line 70: Line 72:
   * Make sure your editor does not change line endings (from Unix LF to DOS CRLF), this would result in a complete file replace, instead of a small patch because each line was changed.   * Make sure your editor does not change line endings (from Unix LF to DOS CRLF), this would result in a complete file replace, instead of a small patch because each line was changed.
   * Make a patch for a single feature. When you worked on two different features (eg, a language fix and a function update), ''add'' and ''commit'' two patches, with one for each feature. Using the ''--patch'' option for ''add'' makes that easy for you by asking what to include in the patch.   * Make a patch for a single feature. When you worked on two different features (eg, a language fix and a function update), ''add'' and ''commit'' two patches, with one for each feature. Using the ''--patch'' option for ''add'' makes that easy for you by asking what to include in the patch.
-  * Patches should be sent to the [[:mailinglist]] and you should explain what they do and why, but we really prefer [[github|pull requests]]+  * We **really prefer** [[github|pull requests]], above patches sent to the [[:mailinglist]]. See below for more guiding for a pull request. You should explain what patches do and why. 
-  * A web interface to the Git repository is available at [[https://github.com/splitbrain/dokuwiki]]+  * A web interface to the Git repository is available at [[https://github.com/dokuwiki/dokuwiki]]
  
-==== Mixing the official tree with own patches ====+===== Use branches and your own fork, for doing pull requests ====
 +(Making [[https://github.com/dokuwiki/dokuwiki/pulls|pull requests]] is the preferred manner of contributing)
  
-FIXME explain branches+Above explanation mixes your changes with the incoming changes of DokuWiki in the same 'branch', and you cannot publish them directly to  Github because you have (probably) not direct commit access to this repository. Therefore, if your intention is to propose your change a //fork// of the repository at Github is needed, in which you can make //branches// for each issue you like to fix. 
 + 
 +First you make at Github your own fork with the 'Fork' button topright on https://github.com/dokuwiki/dokuwiki 
 + 
 +With the clone url, shown with the 'Code' button, you can fetch your fork on your machine. This create the folder 'dokuwiki': 
 + 
 +  git clone git@github.com:YourName/dokuwiki.git 
 + 
 +Next you add the original DokuWiki repository as extra remote repository: 
 + 
 +  git remote add upstream git://github.com/dokuwiki/dokuwiki.git 
 + 
 +Verification of this addition can done by showing all remotes (origin=your online fork, upstream=original online DokuWiki repo) 
 + 
 +  git remote -v 
 + 
 +If you start making the modifications you like to propose, it is recommended to make first a separate branch in your fork. If your plan is to fix multiple issues (e.g. fix php warnings and add a new feature), please create a branch for each of them. A branch can be created with: 
 + 
 +  git checkout -b yourbranchname 
 + 
 +In this branch you can make your changes. Storing changes in git, goes in two steps: 1) first add the files such that git knows which files are ready, 2) commit the added files. 
 + 
 +  # add an entire file to the coming commit 
 +  git add your/file.php 
 +  # or decide interactively which changes in a file to add to the coming commit 
 +  git add --patch 
 + 
 +After done with adding, commit these changes with 
 + 
 +  git commit 
 + 
 +Advice: try to commit small understandable pieces of code per commit, if the entire change is larger, do not all changes in one commit. This helps later other people that review your proposal :-). 
 + 
 +If you wonder what the status is of your repository during the different steps, you can ask git more info: 
 + 
 +  # shows current status, and gives eventually some hints how to progress 
 +  git status 
 +  # show not commit changes 
 +  git diff 
 + 
 +Switching between branches: 
 + 
 +  git checkout yourbranchname 
 +  # back to main branch 
 +  git checkout master 
 + 
 +Sometimes you have changes, which are not yet ready for committing, but you like to switch for example between branches. You can temporary store the not committed changes. 
 + 
 +  # store temporary all not committed changes 
 +  git stash 
 +  # if you like to continue, you can reapply the changes 
 +  git stash apply 
 + 
 +Of course there are regularly changes added to DokuWiki's repository. You can download the history with 
 + 
 +  git fetch upstream 
 + 
 +And next merge them in your branch 
 + 
 +  # go to your branch (if you are not already there) 
 +  git checkout yourbranchname 
 +  # merge the changes from the 'master' branch of the 'upstream' repository  
 +  # in the current branch. 
 +  git merge upstream/master 
 + 
 +Alternatively, you can do the fetching and merging at once with one pull command: 
 + 
 +  git pull upstream master 
 + 
 +If you are ready, and all your changes are committed, you can publish your branch to your fork on Github 
 + 
 +  git push origin yourbranchname 
 + 
 +On Github, you see now a notice which let you initiate a Pull request to DokuWikis repository. DokuWiki's developers will review your proposal and eventually request some changes. 
 + 
 +Changes can be made locally again in your branch, and committed as before. If done, you can publish them in the same manner as the first time. It will simply sent the extra commits to your fork, and automatically appear in the pull request as well. 
 + 
 +  git push origin yourbranchname 
 + 
 +**Background**: 
 +  * [[https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/committing-changes-to-a-pull-request-branch-created-from-a-fork|committing changes to a pull request branch created from a fork]] 
 +  * [[https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork|syncing a fork]] 
 +  * [[https://docs.github.com/en/get-started/using-git/pushing-commits-to-a-remote-repository|pushing commits to a remote repository]] 
 +  * https://training.github.com/downloads/github-git-cheat-sheet/
  
 ==== Maintaining a stable version with Git ==== ==== Maintaining a stable version with Git ====
Line 81: Line 167:
 Git isn't only for DokuWiki developers. It can be used to get the latest stable version and to update to the next stable version when it is released. To do so you need to clone the repository but checkout the stable branch: Git isn't only for DokuWiki developers. It can be used to get the latest stable version and to update to the next stable version when it is released. To do so you need to clone the repository but checkout the stable branch:
  
-  git clone --branch stable https://github.com/splitbrain/dokuwiki.git+  git clone --branch stable https://github.com/dokuwiki/dokuwiki.git
      
 Now you can pull all needed updates whenever a new release is made: Now you can pull all needed updates whenever a new release is made:
Line 88: Line 174:
   git pull   git pull
  
 +
 +==== Adding plugin/template git repositories in the tree===
 +
 +You can checkout your plugin repository (or if contributing to others' plugin, your fork of the plugin) in the tree of the development version. By doing this, it integrates well the [[unittesting|unit tests]] and global Dokuwiki project settings.
 +
 +Go to the plugins (or template) folder
 +
 +  cd dokuwiki/lib/plugins
 +  # or
 +  cd dokuwiki/lib/tpl
 +
 +Clone the plugin repository, this creates the folder 'dokuwiki-plugin-example'
 +
 +  git clone git@github.com:YourName/dokuwiki-plugin-example.git
 +
 +Rename to the correct base name (if you hesitate, check ''[[devel:plugin_info|plugin.info.txt]]'' or ''[[devel:template_info|template.info.txt]]'')
 +
 +  mv dokuwiki-plugin-example example
 +
 +Eventually, you have to configure your IDE to recognize the repository e.g. in [[devel:intellij_idea#mapping_of_plugin_git_repositories|InteliJ IDEA]].
devel/git.1453657792.txt.gz · Last modified: 2016-01-24 18:49 by Aleksandr

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki