Changes

Jump to navigation Jump to search
255 bytes added ,  16:23, 27 February 2020
no edit summary
===Clone Repository===
<pre classsyntaxhighlight lang="brush:shell">
$ git clone git@github.com:$username/$project.git
Cloning into $project...
$ ls -d -1 $PWD/*
/home/user/myprojects/$project
</presyntaxhighlight>
Note that git automatically creates a directory where the repository content will be checked out.
===List Remote Repositories===
<pre classsyntaxhighlight lang="brush:shell">
$ git remote -v
origin git@github.com:$username/$project.git (fetch)
origin git@github.com:$username/$project.git (push)
</presyntaxhighlight>
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.
After some files have been changed locally, the changes can be seen as follows:
<pre classsyntaxhighlight lang="brush:shell">
$ git diff
diff --git a/readme.txt b/readme.txt
Any kind of feedback is welcome; please check out the online documentation at
</presyntaxhighlight>
===Commit to Local Repository===
First, it is needed to select the modified files which should be committed:
<pre classsyntaxhighlight lang="brush:shell">
$ git add readme.txt
</presyntaxhighlight>
Then perform the actual commit:
<pre classsyntaxhighlight lang="brush:shell">
$ git commit
[master 0fde1fb] Added TODO in section "USING GIT"
1 files changed, 4 insertions(+), 0 deletions(-)
</presyntaxhighlight>
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 explicitly add the changed files:
<pre classsyntaxhighlight lang="brush:shell">
$ git commit -a
[master 0fde1fb] Added TODO in section "USING GIT"
1 files changed, 4 insertions(+), 0 deletions(-)
</presyntaxhighlight>
===Pushing Changes to Remote Repository===
<pre classsyntaxhighlight lang="brush:shell">
$ git push
Enter passphrase for key '/home/user/.ssh/id_rsa':
Everything up-to-date
</presyntaxhighlight>
===Pulling Changes from Remote Repository===
<pre classsyntaxhighlight lang="brush:shell">
$ git pull
Enter passphrase for key '/home/user/.ssh/id_rsa':
Already up-to-date.
</presyntaxhighlight>
===Add 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 classsyntaxhighlight lang="brush:shell">
$ git remote add upstream git@github.com:BaseXdb/$project.git
upstream git@github.com:BaseXdb/$project.git (fetch)
upstream git@github.com:BaseXdb/$project.git (push)
</presyntaxhighlight>
===Pulling Changes from Upstream to Local Repository===
When some changes are made in the upstream repository, they can be pulled to the local repository as follows:
<pre classsyntaxhighlight lang="brush:shell">
$ git pull upstream master
Enter passphrase for key '/home/user/.ssh/id_rsa':
* branch master -> FETCH_HEAD
Already up-to-date.
</presyntaxhighlight>
The changes can then be pushed in the personal repository:
<pre classsyntaxhighlight lang="brush:shell">
$ git push
</presyntaxhighlight>
Check out the links at the end of the page for more git options.
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 classsyntaxhighlight lang="brush:shell">
$ git pull upstream master
</presyntaxhighlight>
Now, we create a new branch, based on the master branch
<pre classsyntaxhighlight lang="brush:shell">
$ git checkout -b new-feature
Switched to a new branch 'new-feature'
</presyntaxhighlight>
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 classsyntaxhighlight lang="brush:shell">
$ git commit -a
</presyntaxhighlight>
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 classsyntaxhighlight lang="brush:shell">
$ git push origin new-feature
Counting objects: 318, done.
To git@github.com:$username/basex.git
* [new branch] new-feature -> new-feature
</presyntaxhighlight>
You can now use your web browser and go to your fork of BaseX. You will see the following message:
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu