Week 6

Day 2 - "What?! No backup?"

Attack of the clones

We now know about basic branching and merging. At this stage, there is on important topic we must cover briefly, and this is subject of cloning. Cloning allows you to make a complete copy of your repository, including all of its history and all of the branches. Let us take a look at a situation which could make use of cloning.
In the trenches...
"So John," started Rob, "Just how are we backing up the repository at the moment?"

John thought for a moment before replying. He knew what Rob was getting at, but he hadn't expected Rob to bring the question up in front of Markus. In truth he had forgotten all about it. He turned to Markus.

"I'll be honest Markus. Currently the repository isn't being backed up, but then we are running in parallel with the old system, so it wouldn't be the end of the world if we lost it."

Markus nodded and smiled. It seemed that John had gotten away with it for now and with that, Klaus shot Rob a piercing glance.

"Team," began Markus, "we need a definitive way of backing up the new Git repository, and I'd like it done before the end of the day." He pointed at a document on the table. "This project document has been approved by Wayne, and in there it states we will have a defined backup strategy. Please don't let me down."

* * *

"Rob you really got to be careful about things like that," Klaus said to one of the younger members of the team. "You really showed John up in there."

"Yeh," said Rob, "I realise that now." He stood with his back against the wall and tapped his fingers against the painted surface. "I was wondering, do you think John would let me look at the backup system for him as a way of apologising."

Klaus smiled, it seemed Rob was finally understanding things, "Go ask him," said Klaus, "He's so snowed under with the BurnForce release that he'll probably let you implement it too"

"Right" nodded Rob and off he went.

So cloning is an excellent way of taking a copy of our repository, in essence it is a simple way of taking a backup of our repository and then with a little more work, we can keep that clone up to date. Obviously we could just take the files and copy them, but a better way of doing this is by utilising the git clone command. When cloning a repository, we take the entire structure and replicate it, creating an exact copy of the data in an alternative location. Well, that's what cloning means isn't it?

The git clone tool doesn't just copy the data though, it does several other things. Let us create a clone of our test repository to another local location. In this case, we are going to clone the repository into a folder called coderepo-cl.
john@satsuki:~$ git clone coderepo coderepo-cl
Initialized empty Git repository in /home/john/coderepo-cl/.git/
john@satsuki:~$ cd coderepo-cl
john@satsuki:~/coderepo-cl$ ls
another_file newfile1 newfile2
john@satsuki:~/coderepo-cl$ git status
# On branch master
nothing to commit (working directory clean)
john@satsuki:~/coderepo-cl$

Let us take a few moments to see what has happened here. It would appear that our data has been copied successfully. If you were to run a git log on this dir, you would see all the previous log messages for all our previous commits. You can also see that if we run git status that we are on the same branch here that we were in our repository when we left it. In this case, we are in the master branch.

So this could be sufficient enough to serve as a backup of our repository, but we will actually find a better way to do this a little later.

Previous Day

Next Day

 
   
home | download | read now | source | feedback | legal stuff