I'm new to using Github and I'm trying to get my PHP project in Netbeans to work with Github.
I created a new PHP project from existing sources with the source folder as my network drive which is also being used as the FTP location for my web server. I saved the metadata to my local drive. The git files location is on my local drive with my metadata.
I was able to create initialize repository without any problems but when I try to push my project up to my git repo it shows no local branches I can select.
What am I missing or doing wrong? Thanks for the help!
I was able to create initialize repository
Once the repo is created, you need to add and make an initial commit, in order for a branch (master) to be created.
Then you would be able to select said master branch in order to push.
Related
I am trying to stick this all pieces together, so I have:
Remote:
Dev server, where Http Server + DB + my site - folder, where all files of my future project will be.
Bitbucket account
Locally installed:
PhpStorm
Git
SourceTree
What would be a queue of actions to setup all this stuff to make them work together in right way?
Problems I faced:
If I first create PHP project then I can't clone repository from Bitbucket to not empty folder.
How to tie existing project to newly created repository of Bitbucket? Because usually project starts with creating some skeleton from git, so I can't start with empty project folder...
Imagine I make changes, save it to remote server, check it works, then commit it to Bitbucket then I realize I need back to code which was few commits before.
How could I roll back my project code? And then how will I update this on a remote server? Do I need delete all files and upload them again from project?
Problem 1:
Normaly you start with a local project and push it to the remote but it works also the other way round, checkout the remote repo to your computer and then copy the project files into that folder, then use SourceTree to commit and push them.
Problem 2:
You don't rollout commits, you rollout tags and branches. Best is you start with a master branch where you have everything that works 100% and when you develop and work locally you have a second branch develop for testing. When your tests and stuff in develop branch work, you merge it into the master branch. If you want to go a step further, try git-flow.
I have a number of currently live Magento websites which I'm looking to take copies of and integrate Git with Bitbucket into. I want to do this to make future changes traceable with the ability to be able to roll back should anything go wrong!
Here's how I understand it should work:
Create bitbucket repository
Install .git on both local machines and live server
Download copies of live site files and database
Clone repo to local machine
Import all files into cloned repo
Push back up to repo
Setup php file on live site to git pull from repo
Link php file as a Service Hook in bitbucket
What I need to know is if I'm missing anything from the above steps and how you would migrate a currently live Magento site to your local machine and get it all working again.
First of all here is my suggestion for your Git architecture:
Create two branch in your local and two branch in Bitbucket (Let's name them Dev and Master). It is very important to have a dedicated branch (Master) in Bitbucket that your server securely pulls from it; in this way you try to prevent messing things up.
In your local always push from your Dev branch and merge your Master branch after it. And in your server pull only from Master branch in Bitbucket.
For making a copy of your Magento:
First dump your DB and import it in your local DB. Then copy all the files from public_html folder in your server to your local. You might need to change a few things in your DB (in core_config_data table) and your .htaccess file (Here).
Take the DB user credentials from: app/etc/local.xml file and create this user in your local DB. If you are lucky enough it should do the job if not search for it, you'll find hundreds of dedicated questions/answers all over the Internet.
Apart from these, for automatic updates you should look for CI (continuous integration) tools like Jenkins. Have a look at these links (1, 2).
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.
Switched to 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. 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. 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.
Suggestions?
About setting up your work environment :
In order to set up your bitbucket repository and local clone, go read this link (official doc).
You will need to repeat the cloning part once for each PC (e.g : once on yours, once on your colleague's).
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 ; 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.
Using your local git repository with Netbeans is pretty straightforward :
From netbeans, run the File > New Project ... command (default: Ctrl+Shift+N),
Select PHP application with Existing Sources and click Next >,
For the Sources Folder: line, select your local git directory,
Fill the remaining fields, and if you want the last Run configuration screen, then click 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.
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). 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 :
Save your work to your local repository (git add / git commit)
Download the latest modifications shared by your colleague (git pull)
Upload your work to the central repository (git push)
You can access these commands :
from a terminal,
from a GUI frontend : you can try TortoiseGit for windows, or gitk for linux,
from Netbeans :
in the contextual menu of the files/folders in the project tree (right click on the item, there is a "Git" entry),
using the Team > Git > ... menu
Since you provided a git tag, I'll describe what's to do for Git.
set up a remote bare repo on a server that you both could access (BitBucket in your case):
http://git-scm.com/book/en/Git-on-the-Server-Getting-Git-on-a-Server
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
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
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
Doing so, you will decouple your work from that of your colleague since you're not changing files over FTP all the time. 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.
You can create git or Mercurial repositories in Atlassian Bitbucket (http://bitbucket.org). 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. See NetBeans + Git on BitBucket
You need to create a new repository in bitbucket. I assume you already configure the ssh2 keys. Using Git you need:
git clone --bare --shared php_project php_project.git
git commit
Using Mercurial you need:
hg init
hg commit
Good luck / boa sorte
Pedro
I am very new to github. I was trying to pull a branch from a repository which contains some php code.
I used git clone <url>
then I used git checkout <branchname> to switch to a specific branch.
Since I am using Github for Windows, the files are stored in Github folder of My Documents. Now I want to test the code and make some changes to it in my localserver. So should I copy paste the project folder in the www directory of my wamp folder? Or should I do something else? And if after copying the folder, if I want to commit any changes, what command should I use to push?
Github for Windows does mention in the help page that:
GitHub for Windows is optimized to work with GitHub remotes — but if you wish to use a non-GitHub remote, it will work just fine. Set the remote manually in the settings tab and everything else should work as expected. You can also drag in repositories from the file system and GitHub for Windows will respect the configuration of the origin remote.
So you can pull from a non-GitHub repo, like I did in this answer or as illustrated in this blog post.
But from your local clone, you cannot easily push to another repo (like one in your wamp folder for instance)
it does not support multiple Git remotes and it will only work with the origin remote.
If you wish to push & pull to other remotes, we suggest you use the command line client that is included with the application.
An alternative to command-line would be to use a GUI which does support multiple remote, like SourceTree.
Or you can clone the GitHub repo from the command-line directly in the right folder, and then declare that local repo in your GitHub for Windows app.
Or you could create a virtual host that has a DocumentRoot of the Github folder of My Documents (meaning you don't have to move anything, and can keep using GitHub for Windows as you were).
I am using openshift server to host my php application. I have added files to my server using sftp to ~/app-root/runtime/repo directory. The same files are accesible over the web. But when I git clone my repository to my local machine I don't see my uploaded files in it. Neither when I add and push files using git are seen in my app-root folder. Any help is kindly appreciated
Changes made directly on the gear's repo/ dir are not tracked by git, and will be overwritten when you push your local git repo to the gear. To track them, scp/sftp them back to your local git repo and add/commit/push them across.
The alternative to scp/sftp is to run "rhc snapshot {appName}" which will take a backup of all your files (code and data in case of snapshot), then you can extract the files under the repo/ dir back to your local git repo, and add/commit/push them across.
Feel free to post to our forums: https://openshift.redhat.com/community/forums/openshift