简体   繁体   中英

GIT command for Clone OR Update

I'm migrating to GIT from another source code versioning tool and the workflow is a bit different.

With the old tool I had a build that was automatically started everytime a developer made any change in the remote depot. This build was meant to be fast so did not remove the source code and got it again from the depot. Instead I made an update of the code in the disk with the changes in the remote server.

As far as I known this is a pull in GIT. But to be able to make a pull I need to make a clone before. But for the first build or if for any reason I need to remove the source code I really need a clone of the depot.

So may question is...is there any GIT command to perform a clone if there is nothing in the disk but just an update (pull) if I just need to update the current source code???

Thanks.

Create an alias like in the following example:

alias git-clone-pull='if [[ -d .git ]]; then git pull; else git clone GIT-SERVER-REPOSITORY; fi'

If you execute git-clone-pull inside a Git repository it'll execute the "git pull" command, otherwise it'll execute the "git clone" one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM