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

clone depth does what? Why do I care about this setting?

NPxComplete
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 8, 2017

This question is in reference to Atlassian Documentation: Configure bitbucket-pipelines.yml

Ask your question here...

2 answers

6 votes
Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 8, 2017

Just to extend on what Johannes said: Bitbucket Pipelines uses a "shallow clone" by default to clone your repository into the build environment. If you have a large repository, a shallow clone will decrease the amount of time it takes for you repository to be cloned into the build environment. Typically you will only need to build/test recent commits, so there is no need to get the older ones.

Some deployment tools require the entire repository history in order to work. So the full clone feature exists to support these tools. There were also some issues with old tags not being in the clone (as they were more than 50 commits behind HEAD). So using a full clone (or a larger clone depth) means you can see all the tags in your repository. 

If you don't hit any issues at the moment in regards to cloning, it's likely you can stick with the default. smile

Thanks

Phil

screig August 16, 2018

Hi

I would like to change the depth number on cloning in my pipeline jobs. How can i do that?

Thanks

Sean

Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 19, 2018

Hi Sean,

Try this:

clone:
depth: 5 # or some other number of commits. You can also configure 'full' if you need the entire commit history.

pipelines:
... # standard pipelines stuff from here

 Look here for more details: https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html?_ga=2.243827725.922211975.1534723907-825437565.1515570924#Configurebitbucket-pipelines.yml-ci_cloneclone

Like # people like this
screig August 20, 2018

Great, thanks!

Ihor Sviziev October 9, 2018

Hi @Philip Hodder,

Is it possible to define "depth" only for specific steps? I have one step that requires depth: full, but all another steps doesn't. How can I  do that?

Like # people like this
Shuhrat Dehkanov January 18, 2019

@Ihor Sviziev

Adding `git fetch --unshallow` to that specific step's script block worked for me. E.g.,:

 

tags:
release/*:
- step:
script:
- git fetch --unshallow
# moar commands

Cc: @Philip Hodder 

Like # people like this
Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 21, 2019

Whoops. I missed the question.  @Ihor Sviziev not at the moment. I suggest you open a feature request here for us to track: https://bitbucket.org/site/master/issues/new

Like # people like this
Mateusz Przybyłek June 29, 2020

You can use it directly in step

    - step&dummy
        nameDummy step
        clone:
          depth2
        script:
          - echo "Hello, I am pointless"
Like fry likes this
Marc Wüest
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 8, 2021

If I shallow-clone (e.g. depth 1) and later realize I need a full clone, would I then start over or can I 'complete' the shallow clone to a full clone?

5 votes
Johannes Kilian
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 8, 2017

"Clone depth" is a feature of git to reduce server load: Instead of cloning the complete repository (as usually done with git), using clone depth just clones the last clone-depth-number revisions of your repository.

In literature this is also called "shallow clone"

For example See here: Git Beyond the Basics: Using shallow clones

 

Johannes Kilian
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 8, 2017

As I don't use either bitbucket-cloud nor bitbucket-pipelines, I cannot say what clone depth is used for in this context

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events