php 使用 Git 设置 Laravel 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22275538/
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
Setting up Laravel project with Git
提问by salxander
I'm pretty new to using git, and I wanted to figure out the "best practice" way of setting up a laravel project in my own repo and still be able to fetch updates from the main project (https://github.com/laravel/laravel.git) and merge them with my project?
我对使用 git 还很陌生,我想找出在我自己的 repo 中设置 Laravel 项目的“最佳实践”方式,并且仍然能够从主项目(https://github.com)中获取更新/laravel/laravel.git)并将它们与我的项目合并?
Could anybody walk me through this with step by step commands?
有人可以通过分步命令引导我完成此操作吗?
I would really appreciate it.
我真的很感激。
Thanks!
谢谢!
回答by Antonio Carlos Ribeiro
Laravel default app (https://github.com/laravel/laravel.git) doesn't change much and when it changes, Taylor gives the steps to migrate it. What you really want to do is to keep your project in sync with https://github.com/laravel/framework.git, for that you just have to
Laravel 默认应用程序 ( https://github.com/laravel/laravel.git) 没有太大变化,当它发生变化时,Taylor 给出了迁移它的步骤。你真正想做的是让你的项目与https://github.com/laravel/framework.git保持同步,为此你只需要
composer update
Every day.
每天。
But if you really want to have default app in sync too, here are some steps:
但是,如果您真的希望也同步默认应用程序,请按以下步骤操作:
1) Go to github and fork https://github.com/laravel/framework.git.
1) 去 github 并 fork https://github.com/laravel/framework.git。
2) Install your application as you would normally:
2) 像往常一样安装您的应用程序:
composer create-project laravel/laravel your-project-name --prefer-dist
3) Rename git origin to anything else:
3) 将 git origin 重命名为其他任何名称:
git remote rename origin laravel
4) Create a new project on github and add it as your new origin
4)在github上新建一个项目,添加为新的origin
git remote add origin https://github.com/you/yourproject.git
5) Add, commit and push it:
5) 添加、提交和推送它:
git add -A
git commit -m "first commit"
git push origin master
And you should be good to go.
你应该很高兴去。
Every time you need to merge yours with Laravel's you'll probably need to:
每次你需要将你的与 Laravel 合并时,你可能需要:
1) Fetch the changes
1)获取更改
git fetch laravel
2) Take a look at the list of branches:
2)查看分支列表:
git branch -va
3) Merge yous with laravel
3)将你与laravel合并
git merge laravel/master
回答by Constantin Stan
Use composer when installing laravel. Here is the workflow that you should follow:
安装 Laravel 时使用 Composer。以下是您应该遵循的工作流程:
- install laravel using composer
- create your git repo from the above installation
- start developing your application, commit, push, etc.
- when you want to take the latest changes from laravel just use composer again: composer update, your vendor folder will be updated automatically. Be aware that the vendor folder is ignored by git, in this way you will have a clean commit history that will include only your application commits without the laravel ones.
- 使用composer安装laravel
- 从上面的安装创建你的 git repo
- 开始开发您的应用程序、提交、推送等。
- 当您想从 laravel 获取最新更改时,只需再次使用 composer:composer update,您的供应商文件夹将自动更新。请注意,git 会忽略 vendor 文件夹,这样您将拥有一个干净的提交历史记录,其中仅包含您的应用程序提交,而没有 laravel 提交。
回答by joemalski
How to Setup a Remote Repository with your Laravel Projects:
如何使用 Laravel 项目设置远程存储库:
Create a "remote"repository either using github, bitbucket, etc. Make sure that the repository your creating is "empty"meaning literary empty don't include any Readme.mdyet.
使用github、bitbucket等创建一个“远程”存储库。确保您创建的存储库是“空”的,意思是文学空的不包含任何Readme.md。
Create your laravel project file:
$ composer create-project --prefer-dist laravel/laravel my-app
then cd my-appto the project's root folder.
创建你的 Laravel 项目文件:
$ composer create-project --prefer-dist laravel/laravel my-app
然后cd my-app到项目的根文件夹。
Git Initilization:
Git初始化:
$ git init
$ git remote add <name-of-remote> <remote-path>
ex: git remote add origin https://github.com/youraccount/my-app.git
$ git add .
$ git commit -m "Initial Commit"
$ git push origin master
$ git init
$ git remote add <name-of-remote> <remote-path>
例如:git remote add origin https://github.com/youraccount/my-app.git
$ git add 。
$ git commit -m "Initial Commit"
$ git push origin master
then, check out your "remote repository"if your commits are reflected.
然后,如果您的提交得到反映,请检查您的“远程存储库”。
Next step would be to read up on setting up ssh keys:
https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html
https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/
下一步是阅读设置ssh 密钥:
https: //confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html
https://help.github.com/articles/添加一个新的 ssh-key-to-your-github-account/
To know more about git commands:
https://www.atlassian.com/git/tutorials
要了解有关git 命令的更多信息:https :
//www.atlassian.com/git/tutorials
Happy Coding!
快乐编码!
回答by Mark
You may also try to use Sourcetreeor GitKrakenif you want to have some User Interface when doing versioning control with your project. You will not run anymore git commandsif you will have it.
在对项目进行版本控制时,您也可以尝试使用Sourcetree或者GitKraken如果您想要一些用户界面。git commands如果你有它,你就不会再跑了。

