Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Unable to push to cloned empty repository using Java API (GitCommandBuilderFactory)

I'm not able to push files using the Java API of bitbucket. The following code shows my attempt to add commits to a new and empty repository:

GitCommandBuilderFactory builderFactory; // imported with component-import

// create working directory (outside repository)
Path workTree = createWorkTree(repository);

// cloning repository to working directory

// create the file in the working directory
createFile(file, content);

// add the file

// commit
.message(String.format("Added file %s", filename))

// push - here is where the error occurs
.build(new SingleLineOutputHandler())

After executing the above code snippet, I get the following error:

[INFO] com.atlassian.bitbucket.scm.CommandFailedException: 'C:\Program Files\Git\cmd\git.exe push' exited with code 1 saying: remote: hooks/pre-receive: line 9: /c/Users/$username/Code/$projectname/target/bitbucket/home/shared/data/repositories/14/hooks/pre-receive.d: Is a directory 
[INFO] remote: hooks/pre-receive: line 9: exec: /c/Users/$username/Code/$projectname/target/bitbucket/home/shared/data/repositories/14/hooks/pre-receive.d: cannot execute: Is a directory
[INFO] To C:\Users\$username\Code\$projectname\target\bitbucket\home\shared\data\repositories\14
[INFO] ! [remote rejected] master -> master (pre-receive hook declined)
[INFO] error: failed to push some refs to 'C:\Users\$username\Code\$projectname\target\bitbucket\home\shared\data\repositories\14'

I'm able to commit some files using the 'EditFileCommand,' but this does not fit my needs, as I need to modify some environment variables in the commit. Does anybody have an idea?

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Calling any interview participants for Bitbucket Data Center

Hi everyone,  We are looking to learn more about development teams’ workflows and pain points, especially around DevOps, integrations, administration, scale, security, and the related challeng...

441 views 4 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you