title: How to overrwite directory using kubectl cp
body: <p>I am copying a local directory into Kubernetes pod using <code>kubectl cp</code> command</p>
  
  <pre><code>kubectl cp test $POD:/tmp
  </code></pre>
  
  <p>It copies the <code>test</code> directory into Kubernetes pod <code>/tmp</code> directory.</p>
  
  <p>Now I want to overwrite the test directory in the pod.  I did not find any option to overwrite directory while copying using <code>kubectl cp</code> command.</p>
  
  <p>Currently, I am deleting the test directory from the pod and then copy the directory. </p>
  
  <pre><code>kubectl exec $POD -- sh -c 'rm -rf /tmp/test'
  kubectl cp test $POD:/tmp
  </code></pre>
  
  <p>This is working fine, but in case any error comes while copying, existing directory from pod will also be deleted.</p>
  
  <p>How can I overwrite the pod directory with a local directory without deleting the pod directory first?</p>
  
  <p>Thanks in advance.</p>