Tag Archive for Ujjwal Prajapati

Sync SVN Repo to web directory

Often the case, when we work on a project using version control system like SVN, GIT we would like to sync the repository with the web directory so that we won’t require to manually upload files to FTP. Linux has a utility tool rsync which synchronizes files and directories from one location to another while minimizing data transfer by using delta encoding when appropriate. So, what we can do is checkout the svn repository in one of the directories in linux system as the web directory and then use rysnc to sync between the directories.

Let us assume, you have your web directory as /var/www And you checkout svn in the directory /var/svn.

Now, first we need to update the svn repo.

$ svn update /var/svn 

Next, we do rsync

rsync -rutlzh --partial --delete --progress /var/svn/ /var/www

Options

  • -r – -recursive : recurse into directories
  • -u – -update : skip files that are newer on the receiver
  • -t – -times : transfer modification times along with the files and update them on the remote system.
  • -l – -links : copy symlinks as symlinks
  • -z – -compress : compress file data duing the transfer
  • -h – -human-readable : output numbers in a human-readable format
  • – -partial : keep partially transferred files
  • – -delete : delete extraneous files from the receiving side, but only for the directories that are being synchronized.
  • – -progress : print information showing the progress of the transfer.

Project Setup using GIT

Often when working in a project, you will be using different version control tools like SVN, GIT, Mercurial and so on. With version control, it is possible to work in a collaborative environment without losing any of the data at any of the project stage. It is essential now-a-days to have been used any of the version control for the projects undertaken.

GIT, a distributed version control system is popular and most used now-a-days. Unlike SVN, it does have a local repository refer to as staging area where the local commits are maintained. We can then push these commits to remote repository. Setting up a project using GIT is the first and foremost thing to do and it is easy as running a few commands.

You are given a remote repository url which is basically a GIT repository url that can be anything from github to bitbucket to Atlassian repository whichever vendor that we choose as remote repository. And to start with, we create a folder in our local machine with a project name and run the git bash or git command tools.

Navigate to the project folder in your git command tool:

cd /path/to/your/project/folder

Now, init the git repository

$ git init

This will create the .git folder which will contain all the necessary information regarding your repository. This will also create the branch in your local folder which is master by default.

Now, we will set our name and email for the git repository. This is required to track your activity when you do commits and relevant activities.

$ git config --global user.name "Ujjwal Prajapati"
$ git config --global user.email "meujjwal@gmail.com"

Now, we add remote repository url and give it a name “origin”

$ git remote add origin https://test@bitbucket.org/test/test.git

Now, if you do run this command, it will show you fetch and push repository url

$ git remote -v

Now, we will be running fetch command to fetch the remote repository to our local repository

$ git fetch origin

Now, to merge it with the local copy which is basically empty now and is your master branch, we run the merge commands.

$ git merge origin/master

Now, we will have the local copy of our remote repository instance. We can now work on the files. Once we do some modification, it is essential to put our changes to remote repository which is the push action. But before doing that, we have to add our files and then commit to staging area.

$ git add "readme.txt"

Now, the file is tracked and staged. All we need to do now, is commit the file to staging area running the command.

$ git commit -m "File Added"

Now, to push it to the remote repository, all we have to do is run the push command as:

$ git push origin master

Now, you are all done setting up the project and know how to commit and track the changes. Happy working with GIT!

Happy New Year 2014

With every beginning, comes a new hope. A hope that makes us feel stronger in belief that today is not yesterday or last day. A hope that perceives failures as the step-forward to success. A hope that settles your heart to accept what you have. A hope that seek the peace in mind to not wander in loneliness. A hope that moulds you into better you. A hope that makes the world a better place to live. And, A hope that there is a hope.

And with these many hopes, I hope you all have a good year ahead. Wish you and all, a very Happy New Year 2014.

www.000webhost.com