在 ubuntu 上使用 git 的目录位置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5487383/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 10:29:08  来源:igfitidea点击:

Location of directory using git on ubuntu

gitgithub

提问by shin

I started using github on Ubuntu. I use PHP/MySQL.

我开始在 Ubuntu 上使用 github。我使用 PHP/MySQL。

All my applications are in /var/www directory for development.

我所有的应用程序都在 /var/www 目录中进行开发。

Now should I create .git directory in each application in /var/www/, such as /var/www/myapp1/.git ?

现在我应该在 /var/www/ 中的每个应用程序中创建 .git 目录,例如 /var/www/myapp1/.git 吗?

Or should I copy each application to /home/MyGit/ and create .git directory here?

或者我应该将每个应用程序复制到 /home/MyGit/ 并在此处创建 .git 目录?

How are you doing?

你好吗?

Please let me know. Thanks in advance.

请告诉我。提前致谢。

采纳答案by Jonathan

You should use Git to store source code, which shouldbe separate from production code. So you should have a /home/you/src/appnamedirectory with the source code, which is where you should initialize Git.

您应该使用 Git 来存储源代码,源代码应该与生产代码分开。所以你应该有一个/home/you/src/appname包含源代码的目录,这是你应该初始化 Git 的地方。

When you are happy with an update, check it into Git and copy it to /var/www/.

如果您对更新感到满意,请将其签入 Git 并将其复制到/var/www/.

回答by jrlmx2

Traditionally people have used git to track a single project, so creating a repository for each applications would be the way to go if you like to follow tradition. Unless your entire www folder is an application, I wouldn't make one big git repository.

传统上,人们使用 git 来跟踪单个项目,因此如果您喜欢遵循传统,则为每个应用程序创建一个存储库将是一种可行的方法。除非您的整个 www 文件夹都是一个应用程序,否则我不会创建一个大的 git 存储库。

回答by Micah Carrick

You can do whatever your preference is.

你可以做任何你喜欢的事情。

Personally, I have all of my projects under my home folder and if I do any local testing from /var/www I use a symlink. The reason for this is because my /home directory is mounted on it's own partition and is backed up. So I can re-install Ubunut, wiping out the contents of /var/www, and simply restore my symlinks. My .git repositories are created wherever I have that project within my home directory.

就我个人而言,我的所有项目都在我的主文件夹下,如果我从 /var/www 进行任何本地测试,我会使用符号链接。这样做的原因是因为我的 /home 目录安装在它自己的分区上并进行了备份。所以我可以重新安装 Ubunut,清除 /var/www 的内容,然后简单地恢复我的符号链接。我的 .git 存储库是在我的主目录中有该项目的任何地方创建的。