Pregunta

I am very much new to Git. Can anyone help me understand the follwoing.

  1. I am working on a build script that first checks out/update code from remote repository. I have nothing to do with the local machine . Do still I need to clone the remote repo in my local and checkout code afterwards.
  2. If I clone a repository, does it copy entire code from repo and consume storage on local machine.
  3. If I really need to clone first then checkout/update, in my build script, how will I check (from Python or ANT)that the repository is cloned or not.
¿Fue útil?

Solución

I've found a very helpful git clone syntax for doing builds where you do not need the entire git history of revisions. Note that this seems to require Git version 1.9+:

git clone -b <remoteBranch> --single-branch --depth 1 ssh://username@servername.net:serverport/PathToProject <FolderName>

Notes:

This clones and checks out "remoteBranch" without the other branches, at a depth of 1 (so only the most recent file snapshots) into the folder "FolderName"

Otros consejos

  1. yes
  2. yes
  3. check if the .git directory exists.

See CharelsB’s comment for tips on how to get more detailed answers ;).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top