Loading...
 

Git concepts for SVN users

SVN updates (for all versions of Tiki) is no longer supported. You should get your updates from https://gitlab.com/tikiwiki/tiki. See also: Tiki Version control history.


When moving to Git from SVN, there are some conceptual conflicts that causes a lot of troubles on daily work. This document intends to describe some basic differences between SVN and Git, so SVN users can learn faster and probably avoid problems.

1. Decentralized vs. Centralized workflow

The first big difference between Git and SVN is Git makes possible to have decentralized workflow when collaborating to other developers, while SVN is fully centralized.

On decentralized workflow you can duplicate (fork) a git repository, share this repository with friends while the original has it's own activity. It is also possible to send differences from duplicated repository to the original and fetch differences from original as well.

On centralized workflow, every change needs to be committed to a unique remote repository. Despite the fact you can have SVN mirrors, it is still centralized, because mirrors also get/send changes from/to central repository.

2. Commands equivalence

2.1. Getting the code

Getting trunk branch on SVN
Copy to clipboard
svn co https://svn.code.sf.net/p/tikiwiki/code/trunk tikiwiki

Getting trunk branch on Git
Copy to clipboard
git clone git@gitlab.com:tikiwiki/tiki.git tikiwiki

2.2. Update

Update on SVN
Copy to clipboard
svn update

Update on Git
Copy to clipboard
git pull


When working on a live Tiki files may have been modified on purpose and you don’t want to update them. (like .user.ini, lang/he/custom.php themes/mytheme/).

You can check the status of your working directory (local copy) using
git status
or the "diff" command (see below).


However your working directory (local copy) may be out of synch and git will protect your files and forbid the pull (update) operation for Tiki (the branch used) files.
Git Pull Error

To solve this you can manually checkout (update) the file that is blocking the operation (or shelve it using stash).

Checkout (updating) files from the repository with the branch used on the working copy
Copy to clipboard
git checkout file/path

You should be then able to proceed with git pull.

2.3. Diff

Diff on SVN
Copy to clipboard
svn diff

Diff on Git
Copy to clipboard
git diff


2.4. Status

Status on SVN
Copy to clipboard
svn status

Status on Git
Copy to clipboard
git status

2.5. Switch

Switch on SVN
Copy to clipboard
svn switch https://svn.code.sf.net/p/tikiwiki/code/branches/18.x . svn up

Switch on Git
Copy to clipboard
git checkout 18.x git pull

3. Commit, Pull, Push

When working on SVN workflow, every commit goes directly to SVN server and will be available to other developers when they update their working copies.

But on Git it is very different. When you initialize a git folder, you will have your project files on your working space, a new local Git repository at the root of your project and optionally, a remote repository, like we have on Github or Gitlab.

When you commit your changes using Git, these changes will be saved only in your local repository. To make your commits available to other devs, you have to *push* your changes to a remote repository. Also, if you want to get changes from other devs and apply on your working space, you have to *pull* these changes from remote repository.

Committing on SVN
Copy to clipboard
echo 'my new change in a file' > README svn add README svn ci -m '[FIX] Added changes on README'

Committing on Git
Copy to clipboard
echo 'my new change in a file' > README git add README git commit -m '[FIX] Added changes on README' # It is possible to commit more changes before sending to remote. # After done, just push changes to remote repository git push


This will work fine if you version is up to date (no one committed since you update your checkout).
You will see merge messages and be asked to merge before pulling.
Chances are you’ll have to rebase your checkout (update/merge on your local version) before pushing your changes.

Committing + rebase on Git
Copy to clipboard
echo 'my new change in a file' > README git add README git commit -m '[FIX] Added changes on README' git pull --rebase git push


Another usual case is that your local version have file you modified and/or don’t want to commit (like a theme, custom language file, etc).
Git will see those modified files as "un-stashed" file and will block you from pushing back your committed files. You can use then the following:

Committing + rebase + autostash on Git
Copy to clipboard
echo 'my new change in a file' > README git add README git commit -m '[FIX] Added changes on README' git pull --rebase --autostash git push

4. Branching

To create branches on SVN, you have to create a branch on remote repository as well, so your team mates can have access to your branch. There is no way to create a local branch for testing purposes.

On Git, you create a branch in your local repository. Optionally, this branch can be sent to remote repository, with an extra command for that.

Creating SVN branch
Copy to clipboard
svn copy 'https://svn.code.sf.net/p/tikiwiki/code/trunk' 'https://svn.code.sf.net/p/tikiwiki/code/branches/task-icon-picker' svn co 'https://svn.code.sf.net/p/tikiwiki/code/branches/task-icon-picker' tiki-icon-picker

Creating Git branch
Copy to clipboard
git branch task-icon-picker git checkout task-icon-picker # The last command created a branch on local repository, # so, to send it to remote repository git push -u origin task-icon-picker

5. Mark files to be committed

On SVN, if you have several changes on working space and try to commit that without specifying a file, all those changes will be committed.

But on Git, the behavior is different. You have to mark a file, folder or the entire working copy to be committed and then create the commit to save your changes.

Adding files to commit on SVN
Copy to clipboard
svn add README.html svn ci -m '[NEW] HTML version for README'

Adding files to commit on Git
Copy to clipboard
git add README.html git commit -m '[NEW] HTML version for README' # But if there is no new files and the mission is commit all changes # just use the -a option git commit -a -m '[NEW] HTML version for README'

6. Revert and discard changes

On SVN, when you want to discard changes on your working copy, you use the command revert to discard those changes and start again.

But on Git, the concept to discard changes is different. You take the content of your local repository and copy over files on you working copy. So the changes are discarded. The revert on Git has another meaning.

The revert command on Git creates a commit that undoes the things of the other commit. So, if you added a line on a file and committed that, the revert command will create another commit removing the line on that file.

Discarding changes SVN
Copy to clipboard
echo 'My new line on README' >> README svn revert README

Reverting a revision on SVN
Copy to clipboard
svn merge -c-63929 README

Discarding changes on Git
Copy to clipboard
echo 'My new line on README' >> README git checkout README

Reverting a commit on Git
Copy to clipboard
git revert 4543a31466d48

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
Diagram
Directory (of hyperlinks)
Documentation link from Tiki to doc.tiki.org (Help System)
Docs
DogFood
Draw -superseded by Diagram
Dynamic Content
Preferences
Dynamic Variable
External Authentication
FAQ
Featured links
Feeds (RSS)
File Gallery
Forum
Friendship Network (Community)
Gantt
Group
Groupmail
Help
History
Hotword
HTML Page
i18n (Multilingual, l10n, Babelfish)
Image Gallery
Import-Export
Install
Integrator
Interoperability
Inter-User Messages
InterTiki
jQuery
Kaltura video management
Kanban
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
Terms and Conditions
Theme
TikiTests
Federated Timesheets
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