Loading...
 
(Cached)

Git Tips


Also see Git and SVN combined workflow.

1. Which git repository to clone

git at git.tiki.org:tiki.git

The main repository is git at git.tiki.org:tiki.git You need to have your SSH key registered to that server. Ask luciash <luci@tiki.org>

git at gitlab.com:tikiwiki

An automated mirror. This is what you should clone if you want to do pull requests on https://gitlab.com/tikiwiki/tiki

No need to ask anyone, but you DO need to upload you ssh key to https://gitlab.com/profile/keys

2. Getting the source

2.1. Shallow clone

Tiki development has been going on for nearly 20 years, and the code base is huge. For these two reasons the repository has a huge size and a regular clone will take a lot of time and disk space.

But it is possible to create a shallow clone, which will bring just the last source code version.

Shallow clone of every branch
git clone --depth 1 --no-single-branch git@gitlab.com:tikiwiki/tiki.git tiki

This is quite fast, and uses about 292M of disk space. Probably best for all developers.
bit branch -a works like most people expect and it's easy to switch branch.

If the purpose of the clone is Tiki development, including master and other branches, it is not needed to clone the entire repository, buy you my want to use --depth 100 so you have some useful history. (this will inflate the size to about 455M however.

Shallow clone, single branch
git clone --depth 1 --branch master git@gitlab.com:tikiwiki/tiki.git tiki

The smallest option, but you can't use git branch -a like you normally would. instead you need to use git ls-remote
To add another branch, you need to use the variant below.

This option is best to checkout on production servers. It uses about 187M of disk space

Shallow clone, more than one branch
git clone --depth 1 --branch master git@gitlab.com:tikiwiki/tiki.git tiki
git remote set-branches --add origin '19.x'
git fetch --depth 1  #REALLY important on the first fetch, otherwise that whole branch will be fetched with all history.  That will use up 1.4G  and take a really long time
#For normal operations you can just git fetch normally, is won't unshallow the branch.

It now uses about 187M of disk space, which is barely more than a single branch. This option is best if you rely on expensive data connections and/or have very limited disk space.

2.2. Full clone

Full clone
git clone git@gitlab.com:tikiwiki/tiki.git

This is quite slow, and uses about 3.1G of disk space. However subsequent operations are not any slower, and you have full local history. This is best if you have the time for the initial clone, and you need to work completely offline.

2.3. Full clone with folders per branch

git clone --reference

Full git repository is 3.1G. That's because the whole history is stored locally. Since Tiki setup depends on a lot of libraries, changing branches in a single repository might be impractical, and having one repository for each directory would consume a lot of redundant disk space.

To solve that, start by having a local mirror repository that will be used as reference for all other repositories. This way you can have several repositories that share the local object database. It's like doing a pre-cache of the repository:

Create a local mirror
git clone  --mirror git@gitlab.com:tikiwiki/tiki.git tiki-reference

(This will take some time, have a coffee).

Supposing a developer wants to clone also the branch 19.x, but without cloning the entire repository, the following command should be used.

Checkout against a reference
git clone --branch=19.x --reference=tiki-reference git@gitlab.com:tikiwiki/tiki.git tiki19x


Repeat for other branches.

Now just commit and push normally, and everything should work fine.

Key issues

In practice, git is often based on ssh, which may be confusing if you've never used it before. Among other things, it will ask to accept the key of the remote server the first time you use it.

Accepting the key of the remote server.
clone --mirror git@git.tiki.org:tiki.git tiki.reference
Cloning into bare repository 'tiki.reference'...
The authenticity of host 'git.tiki.org (172.104.234.244)' can't be established.
ECDSA key fingerprint is SHA256:bsX1VZ1KCXiUlequpZc6f+JGBG0xO4HpUSyYnVrXbMs.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'git.tiki.org,172.104.234.244' (ECDSA) to the list of known hosts.
git@git.tiki.org's password:


3. Repository status

git status

You can read about changed files, untracked files and how far is your local repository from the remote repository by using the git status command. More information can be found by typing git help status.

Status
git status

3.1. Status with ignored files

git status --ignored

The command below will list all ignored files present on the working copy. This is useful when trying to commit a file that should be on repository, but it is ignored by a rule present in .gitignore file.

Ignored files status
git status --ignored

4. Status of untracked files

git status -u

Sometimes, depending the task, it is possible that working copy contains a lot of untracked files. But it is possible to check working copy status excluding those files.

Status excluding untracked files
git status -u no


There are other occasions when there is a need to check all untracked files, including files on sub-directories.

Status of all untracked files
git status -u

5. Reading history

To read the commit log, container authors, data and commit messages, you can use the command git log.

Log
git log

5.1. Filtering history

git log --author --since

It is possible to filter logs by author and date, like the snippets below demonstrate.

Filter by user
git log --author=jonnybradley

# --author can be used multiple times
git log --author=jonnybradley --author=drsassafras

Filter by date
git log --since=2018-03-01

# --since is the start date, and --until is the end date
git log --since=2018-03-01 --until=2018-04-31

All together
git log --since=2018-03-01 --until=2018-04-31 --author=jonnybradley --author=drsassafras


For more options, try git help log

6. Adding changes and files

git add

Before committing, the changes you did should be marked as added. So, when you tell git to commit your changes, only files you marked as added will be committed.

Add changes
echo 'My new super file' > src/foo.txt
echo 'Other super file' > src/bar.txt
git add src/foo.txt src/bar.txt


It is possible to add all changes from a folder at once. It also works to add changes from entire working copy, but it is not a good practice.

Add changes
echo 'My new super file' > src/foo.txt
echo 'Other super file' > src/bar.txt
git add src
git commit -m '[NEW] Add new super feature to Tiki'

7. Removing files from Git

git rm

Removing files
git rm src/foo.txt
git commit -m '[FIX] Removed unused file'

8. Committing changes

git commit

After all new or changed files are marked to be committed by using git add, or files were removed by using git rm, it is time to commit these changes to your local repository.

Committing changes
git status
git commit -m '[NEW] Descriptive message about my changes'


There are occasions a developer commits changes from someone else. In this case, it is possible to give the commit the correct author identity.

Committing changes of someone else
git commit --author=someoneelse@example.com  -m '[FIX] Options list for editable icon preference'


When there are changes just on versioned files, there is shortcut to commit these changes at once, by adding -a parameter on git commit.

Different author
git commit -a  -m '[NEW] Descriptive message about my changes'

9. Creating branches

git branch

Creating branches is easy and fast on Git. It is a good idea to have different branches for tasks, features or experiments and keep master branch clean, so you can fetch updates regularly without dealing with conflicts.

Create branch
# create the branch
git branch task-icon-picker
# and then switch to branch
git checkout task-icon-picker


There is a shortcut to create a branch and then switch to it.

Create branch
git checkout -b task-icon-picker


If this local branch is needed for other team mates, it is possible to make it available on remote repository.

Create branch
git push -u origin task-icon-picker


Let's suppose you are working on branch *bugfix-foo*, and you want update your branch with branch master changes.

Merging branches
git checkout bugfix-foo   # switch to branch
git merge master          # bring master changes to current branch

10. Sending work to remote repository

git push

To send your new commits from your local repository to the remote repository, just use the command git push. The command below will send all changes on local branch to the remote branch on remote repository.

Pushing changes
git push

11. Fetching updates

git pull

It is a good practice to stay always up to date with remote repository your team is using. This way you avoid a lot of conflicts. To get remote changes and bring to local repository and working copy, use the command git pull.

The command below will fetch updates from remote repository.

Fetching changes
git fetch


After fetching changes, the local repository and branch should be updated with it. Supposing the branch to be updated is the master, and the current local branch is also master, it is possible to apply changes with the command below.

Applying changes
git merge origin/master


There is a shortcut to fetch and apply changes on current branch, like below.

Fetching and applying
git pull


 Following not finished

A git workflow has to be designed before we can finish this page.


Keywords

The following is a list of keywords that should serve as hubs for navigation within the Tiki development and should correspond to documentation keywords.

Each feature in Tiki has a wiki page which regroups all the bugs, requests for enhancements, etc. It is somewhat a form of wiki-based project management. You can also express your interest in a feature by adding it to your profile. You can also try out the Dynamic filter.

Accessibility (WAI & 508)
Accounting
Administration
Ajax
Articles & Submissions
Backlinks
Banner
Batch
BigBlueButton audio/video/chat/screensharing
Blog
Bookmark
Browser Compatibility
Calendar
Category
Chat
Comment
Communication Center
Consistency
Contacts Address book
Contact us
Content template
Contribution
Cookie
Copyright
Credits
Custom Home (and Group Home Page)
Database MySQL - MyISAM
Database MySQL - InnoDB
Date and Time
Debugger Console
Directory (of hyperlinks)
Documentation link from Tiki to doc.tiki.org (Help System)
Docs
DogFood
Draw
Dynamic Content
Preferences
Dynamic Variable
External Authentication
FAQ
Featured links
Feeds (RSS)
File Gallery
Forum
Friendship Network (Community)
Group
Help
History
Hotword
HTML Page
i18n (Multilingual, l10n, Babelfish)
Image Gallery
Import-Export
Install
Integrator
Interoperability
Inter-User Messages
InterTiki
jQuery
Kaltura video management
Karma
Live Support
Logs (system & action)
Lost edit protection
Mail-in
Map
Menu
Meta Tag
Missing features
Visual Mapping
Mobile
Mods
Modules
MultiTiki
MyTiki
Newsletter
Notepad
OS independence (Non-Linux, Windows/IIS, Mac, BSD)
Organic Groups (Self-managed Teams)
Packages
Payment
PDF
Performance Speed / Load / Compression / Cache
Permission
Poll
Profiles
Quiz
Rating
Realname
Report
Revision Approval
Scheduler
Score
Search engine optimization (SEO)
Search
Security
Semantic links
Share
Shopping Cart
Shoutbox
Site Identity
Slideshow
Smarty Template
Social Networking
Spam protection (Anti-bot CATPCHA)
Spellcheck
Spreadsheet
Staging and Approval
Stats
Survey
Syntax Highlighter (Codemirror)
Tablesorter
Tags
Task
Tell a Friend, alert + Social Bookmarking
Terms and Conditions
Theme
TikiTests
Timesheet
Token Access
Toolbar (Quicktags)
Tours
Trackers
TRIM
User Administration
User Files
User Menu
Watch
Webmail and Groupmail
WebServices
Wiki History, page rename, etc
Wiki plugins extends basic syntax
Wiki syntax text area, parser, etc
Wiki structure (book and table of content)
Workspace and perspectives
WYSIWTSN
WYSIWYCA
WYSIWYG
XMLRPC
XMPP




Useful Tools