Changes

Jump to navigation Jump to search
4,685 bytes added ,  21:46, 20 February 2011
Using git from command line
===EGit & SSH===
EGit uses the [http://www.jcraft.com/jsch JSch] library which is, however, [https://bugs.eclipse.org/bugs/show_bug.cgi?id=326526 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 [http://egit.eclipse.org/r/#change,2037 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 in Command-Line==
 
'''Note''': this 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===
# Create a GitHub user account: [https://github.com/signup/free] (your github user name will be referenced as $username)
# Set up SSH access to GitHub as described [http://help.github.com/key-setup-redirect 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 Your Personal Repository===
 
<pre class="brush:shell">
$ pwd
/home/user/myprojects
 
$ git clone git@github.com:$username/$project.git
Cloning into $project...
Enter passphrase for key '/home/user/.ssh/id_rsa':
remote: Counting objects: 61445, done.
remote: Compressing objects: 100% (10611/10611), done.
remote: Total 61445 (delta 45273), reused 61131 (delta 44975)
Receiving objects: 100% (61445/61445), 49.95 MiB | 1.83 MiB/s, done.
Resolving deltas: 100% (45273/45273), done.
 
$ ls -d -1 $PWD/*
/home/user/myprojects/$project
</pre>
Note that git automatically creates a directory where the repository content will be checked out.
 
===List Remote Repositories===
 
<pre class="brush:shell">
$ git remote -v
origin git@github.com:$username/$project.git (fetch)
origin git@github.com:$username/$project.git (push)
</pre>
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 Changes===
 
After some files have been changed locally, the changes can be seen as follows:
<pre class="brush:shell">
$ 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 ----------------------------------------------------------------------
+
+TODO
+
--------------------------------------------------------------------------------
Any kind of feedback is welcome; please check out the online documentation at
</pre>
 
===Commit to Local Repository===
 
'''Note''': this commit operation does '''not''' commit into the remote repository!
 
First, it is needed to select the modified files which should be committed:
<pre class="brush:shell">
$ git add readme.txt
</pre>
 
Then perform the actual commit:
<pre class="brush:shell">
$ git commit
[master 0fde1fb] Added TODO in section "USING GIT"
1 files changed, 4 insertions(+), 0 deletions(-)
</pre>
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:
<pre class="brush:shell">
$ git commit -a
[master 0fde1fb] Added TODO in section "USING GIT"
1 files changed, 4 insertions(+), 0 deletions(-)
</pre>
 
===Pushing Local Changes to Personal Repository===
 
<pre class="brush:shell">
$ git push
Enter passphrase for key '/home/user/.ssh/id_rsa':
Everything up-to-date
</pre>
 
===Pulling Changes from Personal Repository===
 
<pre class="brush:shell">
$ git pull
Enter passphrase for key '/home/user/.ssh/id_rsa':
Already up-to-date.
</pre>
 
===Add BaseXdb Upstream Repository===
 
The upstream repository is the one from which the BaseX releases are made and the one from which the personal repository was forked.
 
<pre class="brush:shell">
$ 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)
</pre>
 
===Pulling Changes from Upstream Repository to Local Repository===
 
When some changes are made in the upstream repository, they can be pulled to the local repository as follows:
 
<pre class="brush:shell">
$ 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.
</pre>
 
The changes can then be pushed in the personal repository:
<pre class="brush:shell">
$ git push
</pre>
 
Check out the links at the end of the page for more git options.
==Need help using git?==
administrator, Bureaucrats, editor, reviewer, Administrators
98

edits

Navigation menu