Translations
Info
All page names need to be in English.
en da  de  fr  it  ja  km  nl  ru  zh

Tips and Tricks (Git)

From TYPO3Wiki
Jump to: navigation, search

Contents

Gerrit Tricks

If you want to make copy and paste of git commands even more comfortable, make sure to go to settings/prefernces and enable "Use Flash Clipboard Widget", now you have a little button that fills your clipboard with the proper command.

Console Tricks

Colored console output

shell script:
git config --global color.ui auto

Highlight wrong whitespaces in addition:

shell script:
git config --global color.diff.whitespace "red reverse"

Aliases for frequently used commands

You can define numerous aliases for commands or options that you frequently call, the example shows how to define the aliases git hist and git rvmaster

shell script:
git config alias.hist 'log --format="%h %ad | %s%d [%an]" --graph --date=short'
git config alias.rvmaster 'push origin HEAD:refs/for/master'

Current branch in prompt

You can display the current branch and other information in the prompt of your bash command line. It looks like this:

shell script:
user@hostname:~/typo3 (TYPO3_4-4)$

Instructions:

You can additionally display the current state of your branch (like added files, commits, modified files). For an example have a look at the "don't make me think" shell script at [1]

Ignoring Files

The default way to ignore files are .gitignore (per-directory) and .git/info/exclude (per project). You can use a global .gitignore file by specifying it in the global .gitconfig like so:

shell script:
git config --global core.excludesfile ~/.git/.gitignore

Improving your Workflow

Commit Message Template

You can predefine a template for Commit Message, which eases the task of creating them a bit and reminds you about the Commit Message rules.

  • Put the following text into a file outside the repository.
[BUGFIX|FEATURE] 

Description

Fixes: #
Releases: 
  • Configure Git to use the template:
    git config --global commit.template /path/to/the/template-file

Multiple Branches

On your development machine, you might want to share parts of the git repository, when dealing with different installations/clones for different TYPO3 versions. This setup is described in Multiple Branch Setup.

Connecting using the HTTPS protocol

In case your firewall blocks connections to Gerrit's port 29418, you can also use HTTPS (port 443).

As the SSL certificate of review.typo3.org is probably not accepted by your system, you have to disable validation of SSL certificates in Git. To do so, add the following line to ~/.bashrc or ~/.bash_profile:

shell script:
export GIT_SSL_NO_VERIFY=1

Reopen your shell after this step.

Add the following lines to your ~/.gitconfig file:

[url "https://review.typo3.org/p/"]
	insteadOf = git://git.typo3.org/
 
[url "https://review.typo3.org/p/"]
	insteadOf = ssh://review.typo3.org:29418/

Cheat sheets

Go to: typo3.org    
Login, and you can edit.
Personal tools
Namespaces

Variants
Actions