Git
Contents
- 1 Using Git to contribute to BaseX
- 2 Using Git & Eclipse
- 3 Using Git on Command-Line
- 3.1 Preparation
- 3.2 Clone Your Personal Repository
- 3.3 List Remote Repositories
- 3.4 List Local Changes
- 3.5 Commit to Local Repository
- 3.6 Pushing Local Changes to Personal Repository
- 3.7 Pulling Changes from Personal Repository
- 3.8 Add BaseXdb Upstream Repository
- 3.9 Pulling Changes from Upstream Repository to Local Repository
- 4 Need help using git?
Using Git to contribute to BaseX
Our team uses git and GitHub to manage the source code.
All team members have read+write access to the repository, external contributors are invited to fork the project.
Git makes it easy to retain a full copy of the repository for yourself. To get started and running, simply fork BaseX. If forking sounds unfamiliar to you, we suggest to look up some of the documentation listed at the end of this page.
You can then build BaseX with Maven. Using Eclipse is optional.
SetupUsing Git & Eclipse
In the Package Explorer to the left use right-click and choose Import... Select "Projects from Git" and click Next > CloneClick "Clone..." 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. Select the master branch (or arbitrary branches you like) Now choose a location where the local repository is stored: Create <workspace>/repos/BaseX and click "Finish". Create the projectSelect our newly cloned repository and click Next 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 and click finish You are now ready to contribute. EGit & SSHEGit uses the JSch library which is, however, reported to have problems with RSA SSH keys in linux and possibly other platforms. A solution would be to use the variable GIT_SSH and assign it a path to the native SSH executable. According to this change in EGit, the plugin will try to use a native SSH implementation instead of JSch (this, however, may not always work either :( ). Using Git on Command-LineNote: this is not intended to be a complete git reference; it's purpose is to quickly introduce BaseX developers to the most commonly used git commands in the context of the BaseX project. Preparation
Clone Your Personal Repository$ pwd /home/user/myprojects $ git clone git@github.com:$username/$project.git Cloning into $project... Enter passphrase for key '/home/user/.ssh/id_rsa': ... $ ls -d -1 $PWD/* /home/user/myprojects/$project Note that git automatically creates a directory where the repository content will be checked out. List Remote Repositories$ git remote -v origin git@github.com:$username/$project.git (fetch) origin git@github.com:$username/$project.git (push) Currently, there is only one remote repository; it is automatically registered during the clone operation. Git remembers this repository as the default repository for push/pull operations. List Local ChangesAfter some files have been changed locally, the changes can be seen as follows: $ git diff diff --git a/readme.txt b/readme.txt index fabaeaa..cd09568 100644 --- a/readme.txt +++ b/readme.txt @@ -49,6 +49,10 @@ ADDING CHECKSTYLE -------------------------------------------------------------- - Enter the URL: http://eclipse-cs.sourceforge.net/update - Follow the installation procedure and restart Eclipse +USING GIT ---------------------------------------------------------------------- Any kind of feedback is welcome; please check out the online documentation at Commit to Local RepositoryNote: this commit operation does not commit into the remote repository! First, it is needed to select the modified files which should be committed: $ git add readme.txt Then perform the actual commit: $ git commit [master 0fde1fb] Added TODO in section "USING GIT" 1 files changed, 4 insertions(+), 0 deletions(-) Before executing the actual commit, git will open the default shell editor (determined using the $EDITOR variable, usually vi) to enter a message describing the commit changes. Alternative way is to commit all changed files, i. e. it is not needed to add explicitly the changed files: $ git commit -a [master 0fde1fb] Added TODO in section "USING GIT" 1 files changed, 4 insertions(+), 0 deletions(-) Pushing Local Changes to Personal Repository$ git push Enter passphrase for key '/home/user/.ssh/id_rsa': Everything up-to-date Pulling Changes from Personal Repository$ git pull Enter passphrase for key '/home/user/.ssh/id_rsa': Already up-to-date. Add BaseXdb Upstream RepositoryThe upstream repository is the one from which the BaseX releases are made and the one from which the personal repository was forked. $ git remote add upstream git@github.com:BaseXdb/$project.git $ git remote -v origin git@github.com:$username/$project.git (fetch) origin git@github.com:$username/$project.git (push) upstream git@github.com:BaseXdb/$project.git (fetch) upstream git@github.com:BaseXdb/$project.git (push) Pulling Changes from Upstream Repository to Local RepositoryWhen some changes are made in the upstream repository, they can be pulled to the local repository as follows: $ git pull upstream master Enter passphrase for key '/home/user/.ssh/id_rsa': From github.com:BaseXdb/$project * branch master -> FETCH_HEAD Already up-to-date. The changes can then be pushed in the personal repository: $ git push Check out the links at the end of the page for more git options. |
Need help using git?
Installing
For information on how to install git on various platforms please refer to: GitHub: git Installation Guide