Gerrit and maven release plugin

There is a time in your project when you start using Gerrit code review system. When you have maven release plugin to make release, you can be very surprised when you see:

1
2
3
[ERROR] The git-push command failed.  
[ERROR] Command output:
[ERROR] Permission denied (publickey).

This is a situation when we use ssh connections to gerrit. But, when you try to push something to master (ignoring code review), it works! How is that possible?

You probably have in your gitconfig an ssh URL with your user name. But in your project SCM (in pom.xml) you do not have your user name. What user name maven release plugin use? Your computer account name, which is in most cases different than your Gerrit user name.

How to repair it? Define a file in .ssh/config directory with content:

1
2
3
4
Host gerrit  
HostName YOUR_GERRIT_HOST
Port YOUR_GERRIT_PORT
User YOUR_GERRIT_USER_NAME

There may be a lot of other reason why you have Premission denied, but this was the hardest I’ve ever seen.

Listing files in Git

Exploring git ls-files

This post describes, my experiments with git ls-files command.

In repository, we have files:

File structure in repository
1
2
3
4
5
6
7
.DS_Store (Mac OS X, folder settings file)
.git (Git repository file)
.gitignore (Git ignore file)
ignoredFile (Some file, that should be ignored)
inRepo (File in repository)
untracked (Som untracked file)
staged (Staged file)

This command show us, all committed files and staged files.

List files
1
2
3
4
$ git ls-files
.gitignore
inRepo
staged

This command show us, all files that are ignored or untracked. Those files are called ‘other’.

List ignored or untracked
1
2
3
4
$ git ls-files --others
.DS_Store
ignoredFile
untracked

This command show us, all others files, without ignored files. Option exclude-standard means that standard git exclusion files are included.

List others files, without ignored files
1
2
$ git ls-files --others --exclude-standard
untracked

This command show us, all files that are ignored.

List all ignored files
1
2
3
$ git ls-files --ignored --others --exclude-standard
.DS_Store
ignoredFile

In my global git ignore file, there is a rule to ignore all .DS_Store files. In my local git ignore file, there is a rule to ignore ignoredFile file.