简体   繁体   English

NetBeans + FTP + BitBucket

[英]NetBeans + FTP + BitBucket

I know this has been asked before, but I couldn't get the answer I needed. 我知道之前已经问过,但我无法得到我需要的答案。

Currently I'm developing an website using PHP and was using Notepad++ before, and it all worked well because I'm developing with a co-worker so we both keep on changing different files on the FTP. 目前我正在开发一个使用PHP的网站,之前使用的是Notepad ++,这一切都运行良好,因为我正在与同事一起开发,所以我们都在不断更改FTP上的不同文件。

Switched to NetBeans. 切换到NetBeans。 All went ok, pulled the entire website via FTP to my local computer and everytime I edited a file and saved it uploaded to the FTP. 一切顺利,通过FTP将整个网站拉到我的本地计算机,每次我编辑文件并保存上传到FTP。 But, there is a problem. 但有个问题。 If my colleague updates a file, it doesn't update on my local folder. 如果我的同事更新了文件,则不会在我的本地文件夹上更新。 So, I thought: "Let's try versioning". 所以,我想:“让我们试试版本”。

Created a team on bitbucket, created a repository. 在bitbucket上创建了一个团队,创建了一个存储库。 All went ok. 一切顺利。

But now, I'm in a struggle to get everything up and running on both NetBeans (mine and colleague's) so that my colleague is editing a file on his NetBeans and constantly saving so that it gets saved on FTP and only when he stops working on that file push it to BitBucket so that I can pull after. 但是现在,我正努力让所有NetBeans(我和同事)都能正常运行,以便我的同事在他的NetBeans上编辑文件并不断保存,以便在FTP上保存并且只有当他停止工作时在该文件上将其推送到BitBucket以便我可以拉后。

Suggestions? 建议?

Since you provided a tag, I'll describe what's to do for Git. 既然你提供了一个标签,我将描述为Git做些什么。

  1. set up a remote bare repo on a server that you both could access (BitBucket in your case): 在您可以访问的服务器上设置一个远程仓库(在您的情况下为BitBucket):
    http://git-scm.com/book/en/Git-on-the-Server-Getting-Git-on-a-Server http://git-scm.com/book/en/Git-on-the-Server-Getting-Git-on-a-Server
  2. you both clone that remote repo to your local machines: 你们将远程仓库克隆到本地机器:
    http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository#Cloning-an-Existing-Repository http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository#Cloning-an-Existing-Repository
  3. each of you works in her part of the application. 你们每个人都在申请中工作。 When one is done, publish the work to the server: 完成后,将工作发布到服务器:
    http://git-scm.com/book/en/Git-Basics-Working-with-Remotes#Pushing-to-Your-Remotes http://git-scm.com/book/en/Git-Basics-Working-with-Remotes#Pushing-to-Your-Remotes

By now, the remote server holds the version that was just pushed. 到目前为止,远程服务器保存刚刚推送的版本。 What's missing is the deployment of the website. 缺少的是网站的部署。 This has been discussed here: Using GIT to deploy website 这里已经讨论过: 使用GIT部署网站

Doing so, you will decouple your work from that of your colleague since you're not changing files over FTP all the time. 这样做,你将把你的工作与你同事的工作分开,因为你不是一直在通过FTP更改文件。 You work in your part, your partner works on her part. 你在你的工作,你的伴侣在她的工作。 The work is getting merged and then a new version of the website gets published. 工作正在合并,然后发布新版本的网站。

About setting up your work environment : 关于设置工作环境:

  • In order to set up your bitbucket repository and local clone, go read this link (official doc) . 要设置bitbucket存储库和本地克隆,请阅读此链接(官方文档)
    You will need to repeat the cloning part once for each PC (eg : once on yours, once on your colleague's). 您需要为每台PC重复一次克隆部分 (例如:一次在您的PC上,一次在您的同事身上)。
    Read the account management part to see how you can tag your actions with your account, and your colleague's action with his own account. 阅读帐户管理部分,了解如何使用您的帐户标记您的操作,以及您的同事使用自己的帐户操作。
    Start using your git workflow ; 开始使用你的git工作流程; when you are tired of always typing your password to upload modifications to your bitbucket account, take the time to read the ssh keys setup part - read carefully, you will need to execute the procedure once for you and once for your colleague. 如果您厌倦了总是输入密码来修改您的bitbucket帐户,请花时间阅读ssh密钥设置部分 - 仔细阅读,您需要为您执行一次,为您的同事执行一次。

  • Using your local git repository with Netbeans is pretty straightforward : 在Netbeans中使用本地git存储库非常简单:
    From netbeans, run the File > New Project ... command (default: Ctrl+Shift+N ), 从netbeans,运行File > New Project ...命令(默认值: Ctrl+Shift+N ),
    Select PHP application with Existing Sources and click Next > , 选择PHP application with Existing Sources然后单击Next >
    For the Sources Folder: line, select your local git directory, 对于Sources Folder:行,选择您当地的git目录,
    Fill the remaining fields, and if you want the last Run configuration screen, then click Finish . 填写其余字段,如果需要上次Run configuration屏幕,请单击“ Finish
    After the project is created in netbeans, you can modify the Run configuration part by right clicking on the project's icon, selecting the Properties menu entry, and going to the Run configuration item. 在netbeans中创建项目后,可以通过右键单击项目的图标,选择“ Properties菜单项,然后转到“ Run configuration项来修改“ Run configuration部件。

About solving your workflow "problem" : 关于解决您的工作流程“问题”:

Your current FTP workflow can lead you to blindly squash your colleague's modifications (when uploading), or have your colleague's modification blindly squash your own local modifications (when downloading). 您当前的FTP工作流程可能会导致您盲目地压缩同事的修改(上传时),或者让您的同事修改一味地压缩您自己的本地修改(下载时)。 This is bad , and you will generally notice it only after the bad stuff happened - too late. 这很糟糕 ,只有在坏事发生后才会注意到 - 太迟了。

Correctly using version control allows you to be warned when this could potentially happen, and to keep an almost infinite undo stack on the modifications of the project's files. 正确使用版本控制允许您在可能发生这种情况时收到警告,并在项目文件的修改上保留几乎无限的撤消堆栈。 The cost, however, is that both of you will have to add several actions in your day to day workflow - some choices can not be made automatically. 然而,成本是你们两个都必须在日常工作流程中添加几个动作 - 有些选择不能自动完成。
You may find it cumbersome in the beginning, but it really pays off, and quite quickly - we're talking big bucks here. 你可能在一开始就发现它很麻烦,但它确实很有成效,而且很快 - 我们在这里谈论大笔钱。 So use it and learn. 所以使用它并学习。

On top of using Ctrl+S to save your modifications on disk, you and your colleague will need to integrate 3 extra commands in your daily work : 除了使用Ctrl+S将修改保存在磁盘上之外,您和您的同事还需要在日常工作中集成3个额外的命令:

  1. Save your work to your local repository ( git add / git commit ) 将您的工作保存到本地存储库( git add / git commit
  2. Download the latest modifications shared by your colleague ( git pull ) 下载您的同事共享的最新修改( git pull
  3. Upload your work to the central repository ( git push ) 将您的工作上传到中央存储库( git push

You can access these commands : 您可以访问以下命令:

  • from a terminal, 从一个终端,
  • from a GUI frontend : you can try TortoiseGit for windows, or gitk for linux, 从GUI前端:你可以尝试TortoiseGit for windows,或gitk for linux,
  • from Netbeans : 来自Netbeans:
    • in the contextual menu of the files/folders in the project tree (right click on the item, there is a "Git" entry), 在项目树中的文件/文件夹的上下文菜单中(右键单击该项,有一个“Git”条目),
    • using the Team > Git > ... menu 使用Team > Git > ...菜单

You can create git or Mercurial repositories in Atlassian Bitbucket ( http://bitbucket.org ). 您可以在Atlassian Bitbucket( http://bitbucket.org )中创建git或Mercurial存储库。 If your team is new to version control, i advise you no forks in your first project. 如果您的团队不熟悉版本控制,我建议您在第一个项目中不要分叉。

The easy solution ins to use Atlassian SourceTree ( http://www.sourcetreeapp.com/ ) to control your code since there is a bug in netbeans. 由于netbeans存在错误,因此使用Atlassian SourceTree( http://www.sourcetreeapp.com/ )来控制代码的简单解决方案。 See NetBeans + Git on BitBucket 请参阅BitBucket上的NetBeans + Git

You need to create a new repository in bitbucket. 您需要在bitbucket中创建一个新的存储库。 I assume you already configure the ssh2 keys. 我假设您已经配置了ssh2密钥。 Using Git you need: 使用Git你需要:

git clone --bare --shared php_project php_project.git

git commit

Using Mercurial you need: 使用Mercurial您需要:

hg init

hg commit

Good luck / boa sorte 祝你好运/嘘声

Pedro 佩德罗

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

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