When you have a web project that you develop in your computer and at the same time it is running on a server, it is important to keep track of different versions of the same project. Otherwise, Surely you’ll make a mess.
The best way to bring this organization is using Git. Follow the following steps and develop peaceful. If you still do not use Git, you can download it from here: Official download page of Git.
Create a remote repository:
From a remote repositories page, create a new repository.
We can do this easily from the graphical interface.
The most commonly used are Bitbucket and Github.
When asked if you want to create it from an existing repository say “Yes”, and follow the instructions that appear.
Then you can clone your project on your server.
Now you have bound the two local repositories to the remote repository.
See this article for more information about the steps followed so far: Basic commands of Git
Create a new branch in your localhost to develop in it:
git checkout -b new_branch
Develop in your localhost and upload changes:
git add file1 file2 //...
to add specific files, or:
git add .
to add all modified files. And then:
git commit -m "message" git push -u origin --all
Upload changes to the server:
Once connected to the server by ssh, go to the directory of the project and do the following:
git pull git checkout new_branch
Now you can see the changes in your server.
If you want to develop on your server at any time, you can follow the same process in reverse. If you don’t change the branch, you don’t have to use the last command.
As always, for more information you can look at the official website of Git: http://git-scm.com