Transfer existing website to git - php

I have a website which is written in php, jquery. I have just started a repository for it on github, and successfully copied a readme textfile to the site.
How do I (a) integrate the entire website into the git repository? Currently the project_git directory is at the same level as the httpdocs directory. How do I put it inside, but making sure that the website stays up and well?
(b) create a local repository which can push to this site?
Your help will be much appreciated.

Skip the README file for now and copy it.
Create an empty repository on github
git init in the folder where you want to track all your files, e.g. httpdocs
git add .
git commit -m 'first commit'
Add the repo on github as a remote, e.g. git remote add origin < githubpath >
Push up the master branch to github with git push origin master
Now you can add your README, commit and push, or do it in step 3

If you have pushed the README.txt file to github you are all set up (with a local repository). git will not mess with your current directory structure so it should be as easy as:
git add .
git commit -m "first commit of website"
git push origin master
And you should see everything in github

You'll need to provide us with a bit more insight into your file directory structure, and probably what platform you're on would be helpful.
Also note, if you just started a free github account, pushing your site up there will make the source publicly accessible. Just something to consider.
But basically, all you need to do to put the website into github is:
1) Navigate to the root directory of the site
2) Follow the directions on github for creating a bare git repo
3) Run git add ., git commit -m "Initial commit", git push
And you should be done! Especially if you've already pushed things to the site, you've already taken care of the RSA key setup and things :)

Related

how to convert transferring file through ftp to GIt

I want to use GIT in my project. Right now, i download file from FTP server and then upload it after updating the code. I want to use GIT where i download entire code from server and then through commit and push it goes to server. I don't want use some git application that support FTP but actual GIT. How i can achieve this. Thanks.
Due to you already having an existing code base i will be telling you how to add to a repository.
To use git you will need a repository service like Github or Gitlab. Make sure you have an account and create a repository for your project.
Once you have git installed open a command line in the folder
Git init
This will initialize the folder for git, you may have notice a .git file appear in your ide. This hidden folder is the configuration. Depending on the operating system the instructions may be different.
Open a command line terminal in your directory and enter
git config --global user.name “Your Git Repository Username”
git config --global user.email “Your Git Repository Email Address”
Next you will do
Git add .
This will tell git to prepare all of the files in the existing folder.
Git remote add origin “Your git Repository link ending in a .git”
This will tell git to where it is going to upload (push) the files to, i have told it in this command to call the branch(branches are a version you can work in, you could have a beta version, stable etc) origin.
Git commit -m “These are notes for the repository”
This will add notes to the push, normally comment on what has been changed.
Git push
You will be asked to login to GIT to verify the git installation.
This will push/upload the contents of the folder, make sure you have nothing that is personal in this code because unless you have set the repo to private then it will be public by default on most platforms. It will never push the .git folder.
Ok so when you want to download from a repo its best to again setup git via the Git init & git remote add commands
Then you are able to
Git pull origin master
I hope this helped, any questions i will be around to answer them.

local git repository and how to upload HTML and PHP code to webserver

I'm new with git and still a bit confused how to best manage a local repository with a webserver. Until now, I've just used a plain text editor and FileZilla to upload HTML and PHP code to webserver.
Now I would like to use git for versioning and I've created a local repository on my Ubuntu desktop and made some changes to my code. Do I still have to use FileZilla to upload code to webserver or is there a more comfortable way with a git command? - All I found on the web was to use push and pull, but only in conjunction with GitHub - since I don't need to share my code it with others, I don't want to make my code public on GitHub.
Is there a git command to upload commited HTML and PHP files to webserver? Or have I misunderstood something? - Or shall I think about it that my repository is the code on the webserver?
Any help welcome.
Have you git installed on your server?
Push your code to your account repository on GitHub / Gitlab or Bitbucket
2.In your html_public directory, run these commands
To initialize git in the folder
git init
To add your main remote where you will pull / push etc your code
git remote add origin https://your_remote_url.git
Recover the remote code
git pull origin the_branch_you_want_to_recover
or
git clone https://your_remote_url.git
or
git clone -u https://your_remote_url.git the_branch_you_want_to_recover
After intensive research today, I found git-ftp and I think that this add-on is exactly what I was looking for.

How to set up a development environment using git for my wordpress website

I am developing a wordpress website and it is live. I am currently using file-zilla to update my code. Until now I wasn't in need of any version control, but now it seems that I need to manage a repository as well. We have also added two freelancers in a development team. So, it becomes difficult for us to manage development of this website.
I have read several blogs and I came to a decision that I will use Git for version control. However, I am struggling to find proper steps which explain to me about setting up a development environment for a team of freelancers. Also, I got a little information about bitbucket, but I am not sure if that is necessary for me. I am looking for the best answer to get started.
(Assuming you are leaving core Wordpress files alone and working only with themes and / or plugins as is best practice:)
Create a git repository every theme and plugin that you are working on using a server of your choice: I would go with Bitbucket for free private repos that you can invite the devs to.
Since you already have the files pushed by FileZilla, you would go into each of the folders for the themes and plugins you are using and push them as existing repos using SSH like so:
First initilize the repos and commit:
$git init
$git add .
$git commit -a -m "initial commit"
Then push
$git remote add origin git#bitbucket.org:my_org/my_repo.git
$git push -u origin --all # pushes up the repo and its refs for the first time
$git push -u origin --tags # pushes up any tags
If you are editing core files as well which would be highly discouraged, then you would create just one repo for the entire Wordpress folder, and then initialize, add, commit and push as above.
Development environments would be set up by the devs themselves using the platforms of their choice. Or ask them to use Vagrant if you want them to have similar environments.

How to merge a none git directory with 90% same files into a repository

I started a web project without git.
Now I created a project on bitbucket and commited the a backup from 10 days ago. That means a local copy created with git init add and so one but the latest changes were 10 days in the past.
On my webserver is the current version in about 10% of all files have changed but there is no git initialised at the moment.
So now I want to push all files from my server to the master branch so that I can see the differences.
But how do I accomplish this if the new version is neither a clone nor a seperate branch but just the same folder and file structure as my git repos master with a few changes.
Well I like to switch completely to git but I need to visualize the diffrences between the old and the current version for other developers :(
Any idea?
Thank you
Given a working directory with master checked out, you simply copy the files from the webserver onto it. git diff will show you the differences. If you do git add . && git commit "as per webserver", you'll sync your master with the webserver.

How to share git branches that are based on same repository?

I am a novice programmer, and completely new to GitHub. I am collaborating with a colleague on a project he has been working on over the years.
So Far:
He created a repository and loaded up all the initial files. I forked it into my account, so that I could work on it separately.
Now:
How can I make a commit to my repository and share it with him, so that he can check out the changes and incorporate them into his repository IF he likes the changes?
I know there is a lot of information on GitHub, but I'm not even sure where to start. Any help is greatly appreciated.
Clone
Make Changes and Track it
Commit
Push to your github repo
Pull to your friends repo
Recommended approach in your case is collaborating with your friend.
Here is how:
Add a collaborator
Read this: Will give you basics of git and how to collaborate with others.
There are many ways to do this, github recommends pull requests and unless you have no push access to the repository you will need to do this or send patches. There is an example of such a workflow here
git clone git#github.com:<their repo> [optional folder name]
cd reponame (or optional folder name)
If the repository has submodules then
git submodule update --init (if the repo has submodules)
git submodule foreach 'git checkout <their working branch>'
Fork the code. Fork the specific repository you plan to work on. This will give you your own copy of the project. Set up git in the repository you plan to work on.
cd <repo dir or optional one chosen)
git remote set-url origin git#github.com:<your github name>/<your repo>.git
git remote add --track next upstream git://github.com/<their github name>/<their repo>.git
That is your repository set up to help with code. You can do git pull, git push, etc. (this will be to/from your fork). To pull in changes from a branch of the partner repo, just do:
git pull upstream branch
You will not be able to git push to their repo, for that you need to do a pull request.
When you are happy then go to github (your project) and select diff and pull request. This allows you to put in a message and the lib maintainer will get a message to attend to the request. It will also show if your pull request will merge cleanly, it is unlikely to be accepted if the maintainer has to fix code.

Categories