Changes

Jump to navigation Jump to search
402 bytes removed ,  18:39, 1 December 2023
m
Text replacement - "syntaxhighlight" to "pre"
This page is part of the [[Developer Section]]. It describes how to use [httphttps://git-scm.com/ git] to manage the BaseX sources.
==Using Git to contribute to BaseX ==
==Using Git & Eclipse==
 
<table cellspacing='0' cellpadding='0' width='100%'>
<tr><td valign='top'>
[[File:Git01.png|border|300px|left]]
[[File:Git02.png|border|300px|left]]
[[File:Git03.png|border|300px|left]]
[[File:Git04.png|border|300px|left]]
[[File:Git05.png|border|300px|left]]
[[File:Git06.png|border|300px|left]]
[[File:Git07.png|border|300px|left]]
[[File:Git08.png|border|300px|left]]
[[File:Git09.png|border|300px|left]]
[[File:Git10.png|border|300px|left]]
</td><td valign='top'>
===Clone===
* In the '''Package Explorer''' to the left, use right-click and choose '''Import...'''
* Select '''Projects from Git''' and click '''Next &gt;'''
* Choose the '''Clone''' option to create a local copy of the remote repository. This copy will include the full project history
* Copy & Paste the GitHub URI in the Location field. If you want to use SSH, make sure you provided GitHub with your public key to allow write-access. If in doubt, use the https URI and authenticate yourself with your GitHub credentials. The read-only URI of the repository is {{Code|https://github.com/BaseXdb/basex.git}}.
* Select the master branch (or arbitrary branches you like)
* Now choose a location where the local repository is stored: Create &lt;workspace&gt;'''/repos/BaseX''' and click "'''Finish'''".
 
<gallery>
File:Git01.png|Package Explorer
File:Git02.png|Projects from Git
File:Git03.png|Clone
File:Git04.png|GitHub URI
File:Git05.png|Select Branch
File:Git06.png|Location
</gallery>
===Create the project ===
* Select "'''Import Existing Projects'''" and depending on your Eclipse version enable automatic sharing. More recent versions will not offer this feature as sharing is enabled by default.
* Click next to select the Project to import
* Check "basex" to checkout check out and click finish
* You are now ready to contribute.
 
<gallery>
File:Git07.png|Select Repository
File:Git08.png|Import existing Projects
File:Git09.png|Select basex Project
</gallery>
===EGit & SSH===
The Eclipse git plugin uses the [http://www.jcraft.com/jsch / JSch] library, which had [https://bugs.eclipse.org/bugs/show_bug.cgi?id=326526 problems with RSA SSH keys] in Linux and possibly other platforms. If the problem persists, the path to the native SSH executable can be assigned to the {{CpdeCode|GIT_SSH}} variable. According to [http://egit.eclipse.org/r/#change,2037 this] change in EGit, the plugin will try to use a native SSH implementation instead of JSch.
==Using Git on Command-Line==
'''Note''': this is not intended to be a complete git reference; it's its purpose is to quickly introduce BaseX developers to the most commonly used git commands in the context of the BaseX project.
===Preparation===
# Create a GitHub user account: [https://github.com/signup/free here] (your github user name username will be referenced as $username)# Set up SSH access to GitHub as described [httphttps://helpdocs.github.com/keyen/github/authenticating-to-github/connecting-to-github-setupwith-redirect ssh here]
# Create a fork of one of the BaseXdb projects (it will be referenced as $project)
# Choose a directory where the project will be created and make it your working directory (e. g. /home/user/myprojects)
===Clone Repository===
<pre classlang="brush:shell">
$ git clone git@github.com:$username/$project.git
Cloning into $project...
===List Remote Repositories===
<pre classlang="brush:shell">
$ git remote -v
origin git@github.com:$username/$project.git (fetch)
After some files have been changed locally, the changes can be seen as follows:
<pre classlang="brush:shell">
$ git diff
diff --git a/readme.txt b/readme.txt
First, it is needed to select the modified files which should be committed:
<pre classlang="brush:shell">
$ git add readme.txt
</pre>
Then perform the actual commit:
<pre classlang="brush:shell">
$ git commit
[master 0fde1fb] Added TODO in section "USING GIT"
Alternative way is to commit all changed files, i. e. it is not needed to explicitly add the changed files:
<pre classlang="brush:shell">
$ git commit -a
[master 0fde1fb] Added TODO in section "USING GIT"
===Pushing Changes to Remote Repository===
<pre classlang="brush:shell">
$ git push
Enter passphrase for key '/home/user/.ssh/id_rsa':
===Pulling Changes from Remote Repository===
<pre classlang="brush:shell">
$ git pull
Enter passphrase for key '/home/user/.ssh/id_rsa':
The upstream repository is the one from which the BaseX releases are made and the one from which the personal repository was forked.
<pre classlang="brush:shell">
$ git remote add upstream git@github.com:BaseXdb/$project.git
When some changes are made in the upstream repository, they can be pulled to the local repository as follows:
<pre classlang="brush:shell">
$ git pull upstream master
Enter passphrase for key '/home/user/.ssh/id_rsa':
The changes can then be pushed in the personal repository:
<pre classlang="brush:shell">
$ git push
</pre>
It is always a good idea to create a new branch for a new feature or a big fix you are working on. So first, let's make sure you have the most up-to-date source code. We assume, that you added BaseX as upstream repository as described above and you are currently in the ''master'' branch:
<pre classlang="brush:shell">
$ git pull upstream master
</pre>
Now, we create a new branch, based on the master branch
<pre classlang="brush:shell">
$ git checkout -b new-feature
Switched to a new branch 'new-feature'
Your are now automatically switched to the ''new-feature'' branch. Now you can make all your changes in one or several commits. You can commit all changes using
<pre classlang="brush:shell">
$ git commit -a
</pre>
Now, you want to push these changes to the repository on GitHub. Remember, that up to now your changes just reside on your local drive, so now you want to push it to your remote fork of BaseX. Simply do:
<pre classlang="brush:shell">
$ git push origin new-feature
Counting objects: 318, done.
==Links==
* [httphttps://helpdocs.github.com/giten/github/getting-started-installationwith-redirectgithub/ set-up-git GitHub: git Installation Guide]* [httphttps://help.github.com/ Comprehensive Getting Starting Guide on GitHub]* [httphttps://book.git-scm.com/index.html The git book]* [http://gitcasts.com/ Gitcasts.com – Video Guides]
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu