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.
Related
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.
I want to upgrade my website without downtime. I made researches and didn't find a way to upgrade it without downtime (few seconds are fine). I was thinking a way as follows, but I am not sure whether any good professional way is there. Please help me out on how to improve this.
Add new tables/CFs to the database (database is Cassandra,
we are not supposed to do any changes in existing tables/CF)
Deploy the project in online server in different Directory, so that
users can still use the existing site.
Point the uploaded project in different port and check whether
everything is working properly.
If everything is working change the symlink to the uploaded directory
Please let me know any other good methodology if you have.
I am using SVN in my local server
UPDATING THE SERVER ALMOST INSTANTANEOUSLY
Ok for this one of the best and the easiest method is using Git. So, what you should do is host your code in Git and then whenever you want to update the site, just SSH into the server and do a Git Pull. It's instantaneous and it would update it. Also you can use Git Hooks to further solve your problem as well.
There are a few ways you can go about it, but one of the easier methods would be this.
Let me explain it in detail on how to do it:
The source for your web site should live in a Git repository on the local workstation. I shall describe how I set things up so that I can make changes live by running just "git push online".
The local repository
It doesn't really matter how the local repository is set up, but for the sake of argument, let's suppose you're starting one from scratch.
$ mkdir somesite && cd somesite
$ git init
Initialized empty Git repository in /home/sankalpsingha/somesite/.git/
$ echo 'Test!' > index.html
$ git add index.html
$ git commit -q -m "This is the first push."
The remote repository
I assume that the web site will live on a server to which you have ssh access, and that things are set up so that you can ssh to it without having to type a password (i.e., that your public key is in ~/.ssh/authorized_keys and you are running ssh-agent locally).
On the server, we create a new repository to mirror the local one.
$ mkdir coolsite.git && cd coolsite.git
$ git init --bare
Initialized empty Git repository in /home/sankalpsingha/coolsite.git/
Now lets make and define the hoolks as a post-receive hook that checks out the latest tree into the web server's DocumentRoot (this directory must exist; Git will not create it for you):
$ mkdir /var/www/www.somesite.org
$ cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/var/www/www.somesite.org git checkout -f
$ chmod +x hooks/post-receive
Back on the workstation, we define a name for the remote mirror, and then mirror to it, creating a new "master" branch there.
$ git remote add online ssh://server.somesite.org/home/sankalpsingha/coolsite.git
$ git push online +master:refs/heads/master
On the server, /var/www/www.somesite.org should now contain a copy of your files, independent of any .git metadata.
The update process
Just run :
$ git push online
This will transfer any new commits to the remote repository, where the post-receive hook will immediately update the DocumentRoot for you.
(This is more convenient than defining your workstation as a remote on the server, and running "git pull" by hand or from a cron job, and it doesn't require your workstation to be accessible by ssh.)
You can use some CI or deployment tools. I'm doing this manually. Here is the way i'm doing it.
I have a workcopy directory from git, and git hook to sync it on push.
Then i sync worckopy directory with site using rsync.
All database changes done with migrations, so 1 command yiic migrate is enough to make new tables or alter existing.
With this methodology there is no actuall downtime, some pages can be unavailable for 5-10 sec max, but all system works on this time.
Point the uploaded project in different port and check whether
everything is working properly. If everything is working change the
symlink to the uploaded directory
It's bad way, for testing you need test server, or test it on local machine with same configs and params as on server. For example Vagrant can make any environment on your local machine for testing.
If you need to pass tests (e.g. unit tests or functional), then watch on CI tools.
I am a php developer. I have installed Git on my system(ubuntu 12.04). Now i want to make my system as server and my colleague's systems as clients. ie, a local sharing. Is it possible? we are using eclipse as the editor. We have installed the EGIT plugin in our system. I am very new in Git.Please help me.
Run git daemon to serve your local git repository:
$ git daemon --export-all --base-path=$(pwd)
.. assuming pwd path is at your git repository..
Then others can either clone your repository or just pull from it if they already have the same repository cloned from a common origin:
e.g.
git remote add yourname git://your-ip-address/repo-name
git pull yourname master
First, you need a static local IP address on the server (or a local DNS hostname.) Let's suppose you have a static local ip of 192.168.1.23
Next your colleagues need to have permission to access /home/user/Project. The simplest way is to do this (on the server):
adduser gituser
chown -R gituser /home/user/Project
Now everything in your repo is owned by gituser. Give the password for gituser to your colleagues.
Next, on the client(s), run
git clone gituser#192.168.1.23:/home/user/Project
This should create a copy of your repo on the client.
As for EGit, I recommend leaving that aside until you are more experienced with using Git on the command line. Egit may be easier to use once you understand it, but it is NOT easier to learn.
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
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 :)