简体   繁体   English

克隆或更新的GIT命令

[英]GIT command for Clone OR Update

I'm migrating to GIT from another source code versioning tool and the workflow is a bit different. 我正在从另一个源代码版本控制工具迁移到GIT,工作流程有点不同。

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. 据我所知,这是GIT的pull But to be able to make a pull I need to make a clone before. 但是为了能够拉动我需要先制作一个clone 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. 但是对于第一次构建或者由于任何原因我需要删除源代码我真的需要一个库的clone

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??? 所以可能有问题是......如果磁盘中没有任何内容,只有一个GIT命令执行克隆,而只是更新(拉),如果我只需要更新当前源代码???

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. 如果在Git存储库中执行git-clone-pull,它将执行“git pull”命令,否则它将执行“git clone”命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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