How to Solve Error Message fatal: Dirty repository: Having uncommitted changes. Exiting… upon executing git ftp push

This is an error generated upon executing a command of ‘git ftp push’ or ‘git-ftp push’. The command itself is actually a command executed in a CLI-environment or in a Command Line Interface terminal. The command itself is intended to push files and even folders to a Git-based repository such as Gitlab, Gitblit or any other Git-based repository tools.

Based on the manual page, it can be fathomed that it is a Git tool powered by FTP client. This tool is used to push the changes of files or folders in the Git local repository to a Git remote repository which is accessed through an FTP utility. The error can be shown as follows :

user@hostname:~/source-code$ git ftp push
fatal: Dirty repository: Having uncommitted changes. Exiting...
user@hostname:~/source-code$

But before finally pushing the files or folders to a Git-based repository, there are several steps taken before which is shown as follows :

1. Add the modified files or folders in the local Git-based repository.

user@hostname:~/source-code$ git add *

The command above is executed to add modified files or folders’s content to an index in order to be staged for further commit.

2. Commit all the modified files or folders which has already been added in the index of staging phase for further commit. Below is the execution command :

user@hostname:~/source-code$ git commit -m "Commit Files and Folders"

Actually the above git commit is executed so that the actual changes of files or folders stated in the index of staging are written into the local repository.

3. Push all the files or folders modified which are already committed. The command for pushing the committed modified files or folders in the local Git-based repository to another Git-based repository normally it is remotely located is shown below :

user@hostname:~/source-code$ git push 
Username for 'http://app.repository.com': user
Password for 'http://user@app.repository.com':
Counting objects: 2, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 232 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
To http://app.repository.com/gitlab/user/application.git
d16772a..89e15a4 master -> master
user@hostname:~/source-code$

But apparently after pushing the already committed files or folders in the local repository, in order to backup the source files or folders into another remote Git-based repository which exist and it can actually be accessed via FTP service, the following command execution to push the already committed folders or files in the local repository ends in failure. Below is the actual command execution :

user@hostname:~/source-code$ git ftp push
fatal: Dirty repository: Having uncommitted changes. Exiting...
user@hostname:~/source-code$

The following is actually step taken to solve the problem :

Just type ‘git commit -am “Message”‘ in the commit step for writing the changes of files or folders in the local repository. Just repeat the step above but in the second step which is committing the modified files or folders, modify the command by adding ‘-a’ parameter. Below is the actual command execution :

user@hostname:~/source-code$ git commit -am "Remodelling Directory"
[master 89e15a4] Remodelling Directory
 36 files changed, 11 deletions(-)
 delete mode 100644 ...
 delete mode 100644 ...
 delete mode 100644 ...
 ...
 user@hostname:~/source-code$

The additional parameter ‘-a’ in the git commit command will forced to note the changes not only the modified files or folders but also those files or folders deleted. Previously in the git commit command which is executed without ‘-a’ additional parameter only noted the files or folders changed or modified.

After successfully executed the above command, just try to execute the commad to push again to the remote repository which is accessed through FTP service as follows :

user@hostname:~/source-code$ git ftp push
There are 123 files to sync:
[1 of 123] Buffered for upload '...'.
[2 of 123] Buffered for upload '...'.
[3 of 123] Buffered for upload '...'.
...
Uploading ...
[23 of 123] Buffered for upload '...'.
[24 of 123] Buffered for upload '...'.
[25 of 123] Buffered for upload '...'.
[41 of 123] Buffered for delete '...'.
[42 of 123] Buffered for delete '...'.
[43 of 123] Buffered for delete '...'.
[44 of 123] Buffered for upload '...'.
[45 of 123] Buffered for upload '...'.
Uploading ...
[46 of 123] Buffered for upload '...'.
[47 of 123] Buffered for upload '...'.
[48 of 123] Buffered for upload '...'.
Uploading ...
[79 of 123] Buffered for upload '...'.
[80 of 123] Buffered for upload '...'.
[81 of 123] Buffered for delete '...'.
[82 of 123] Buffered for delete '...'.
Uploading ...
Deleting ...
Last deployment changed to xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
user@hostname:~/source-code$

Leave a Reply

  1. Pingback: All Git Articles - Just Another Sharing Site ...