Loading...
 

Git Tips

1. Getting the source

git clone

Tiki repository has a huge size and a regular clone will take a lot of time. If the purpose of the clone is Tiki development, including master and other branches, it is needed to clone the entire repository.

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

1.1. Shallow clone

git clone --depth 1

But when using a continuous integration system or any kind of automation process depending on latest Tiki source, it possible to create a shallow clone, which will bring just the last source code version.

Shallow clone
git clone --depth 1 git@gitlab.com:tikiwiki/tiki.git tiki

1.2. Full clone with folders per branch

git clone --reference

Some developers have multiple folders per branch, but it does not mean they have a full clone per folder. They clone the full repository once and then, they clone other branches, but referencing the full clone folder.

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


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

Full clone
git clone --branch=18.x --reference=tiki-reference git@gitlab.com:tikiwiki/tiki.git tiki18x

2. 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

2.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

3. 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

4. Reading history

git log

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

Log
git log

4.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

5. 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'

6. Removing files from Git

git rm

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

7. 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'

8. 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

9. 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

10. 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.


Created by amette. Last Modification: Tuesday 21 August, 2018 11:00:48 GMT-0000 by luciash d' being.

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 7.x
Administration
Ajax 2.x
Articles & Submissions
Backlinks
Banner
Batch 6.x
BigBlueButton audio/video/chat/screensharing (5.x)
Blog
Bookmark
Browser Compatibility
Calendar
Category
Chat
Comment
Communication Center
Consistency
Contacts Address book
Contact us
Content template
Contribution 2.x
Cookie
Copyright
Credits 6.x
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 8.x
DogFood
Draw 7.x
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 3.x
Mobile Tiki and Voice Tiki
Mods
Modules
MultiTiki
MyTiki
Newsletter
Notepad
OS independence (Non-Linux, Windows/IIS, Mac, BSD)
Organic Groups (Self-managed Teams)
Packages
Payment 5.x
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 3.x
Share
Shopping Cart 5.x
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 2.x
Task
Tell a Friend, alert + Social Bookmarking
Terms and Conditions
Theme
TikiTests 2.x
Timesheet
Token Access
Toolbar (Quicktags)
Tours
Trackers
TRIM
User Administration
User Files
User Menu
Watch
WebHelp
Webmail and Groupmail
WebServices 3.x
Wiki 3D
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 4.x
WYSIWTSN 4.x
WYSIWYCA
WYSIWYG 2.x
XMLRPC
XMPP




Useful Tools