Basic Git Commands

Standard

Here is a list of some basic Git commands to get you going with Git Repositories.

Task Description Command
Create a new local repository
1
git init
git init
Check out a repository Create a working copy of a local repository:
1
git clone /path/to/repository
git clone /path/to/repository
For a remote server, use:
1
git clone username@host:/path/to/repository
git clone username@host:/path/to/repository
Add files Add one or more files to staging (index):
1
2
3
git add <filename>
 
git add *
git add <filename>

git add *
Commit Commit changes to head (but not yet to the remote repository):
1
git commit -m "Commit message"
git commit -m "Commit message"
Commit any files you’ve added with git add, and also commit any files you’ve changed since then:
1
git commit -a
git commit -a
Push Send changes to the master branch of your remote repository:
1
git push origin master
git push origin master
Status List the files you’ve changed and those you still need to add or commit:
1
git status
git status
Connect to a remote repository If you haven’t connected your local repository to a remote server, add the server to be able to push to it:
1
git remote add origin <server>
git remote add origin <server>
List all currently configured remote repositories: git remote -v
Branches Create a new branch and switch to it:
1
git checkout -b <branchname>
git checkout -b <branchname>
Switch from one branch to another:
1
git checkout <branchname>
git checkout <branchname>
List all the branches in your repo, and also tell you what branch you’re currently in:
1
git branch
git branch
Delete the feature branch:
1
git branch -d <branchname>
git branch -d <branchname>
Push the branch to your remote repository, so others can use it:
1
git push origin <branchname>
git push origin <branchname>
Push all branches to your remote repository:
1
git push --all origin
git push --all origin
Delete a branch on your remote repository:
1
git push origin :<branchname>
git push origin :<branchname>
Update from the remote repository

 

Fetch and merge changes on the remote server to your working directory:
1
git pull
git pull
To merge a different branch into your active branch:
1
git merge <branchname>
git merge <branchname>
View all the merge conflicts:

View the conflicts against the base file:

Preview changes, before merging:

git diff

git diff --base <filename>

1
git diff <sourcebranch> <targetbranch>
git diff <sourcebranch> <targetbranch>
After you have manually resolved any conflicts, you mark the changed file:
1
git add <filename>
git add <filename>
Tags You can use tagging to mark a significant changeset, such as a release:
1
git tag 1.0.0 <commitID>
git tag 1.0.0 <commitID>
CommitId is the leading characters of the changeset ID, up to 10, but must be unique. Get the ID using:
1
git log
git log
Push all tags to remote repository:
1
git push --tags origin
git push --tags origin
Undo local changes If you mess up, you can replace the changes in your working tree with the last content in head:

Changes already added to the index, as well as new files, will be kept.

1
git checkout -- <filename>
git checkout -- <filename>
Instead, to drop all your local changes and commits, fetch the latest history from the server and point your local master branch at it, do this:
1
2
3
git fetch origin
 
git reset --hard origin/master
git fetch origin

git reset --hard origin/master
Search Search the working directory for foo(): git grep "foo()"

Add a Skype call link in HTML

Standard

We can use <a href=”skype:theacidfrog”>Call the acid frog Web Design Leeds on Skype</a> to create a link to Skype. In order for this link to work correctly the user must have Skype installed on their machine.

Examples

Call a skype user

1
<a href="skype:theacidfrog?call">call theacidfrog with Skype</a>
<a href="skype:theacidfrog?call">call theacidfrog with Skype</a>

Send an Skype IM message to a Skype user

1
<a href="skype:theacidfrog?chat">Chat with theacidfrog</a>
<a href="skype:theacidfrog?chat">Chat with theacidfrog</a>

Send a voicemail to a Skype user

1
<a href="skype:theacidfrog?voicemail">Send voicemail to theacidfrog</a>
<a href="skype:theacidfrog?voicemail">Send voicemail to theacidfrog</a>

Create a Skype conference call with multiple users

1
<a href="skype:theacidfrog;anothercontact?call">conference call with theacidfrog and anothercontact</a>
<a href="skype:theacidfrog;anothercontact?call">conference call with theacidfrog and anothercontact</a>

Create a conference chat with multiple users

1
<a href="skype:theacidfrog;anothercontact?call">conference call with theacidfrog and anothercontact</a>
<a href="skype:theacidfrog;anothercontact?call">conference call with theacidfrog and anothercontact</a>

Search Enginge Optimisation and Copywriting in Leeds

Standard

What is Search Engine Optimisation?

Search Engine Optimisation (SEO) is to increase the ranking of websites in search engines. We incorporate a range of elements to promote your business on the web. We will adjust elements of your website to ensure the site foundation is search engine friendly.

Search engines are constantly changing their criteria to improve the accuracy of their searches. This means we have to keep working hard to maintain high positions for your website. To maintain a high ranking, we monitor search engine activity, perform ongoing tests and trial new techniques constantly.

SEO Copywriting

Once you’ve got your shiny new website, you need to populate it with engaging and effective content in order to capture your audience and generate sales. Our professional copywriting services will ensure that your website is delivering the right message to your visitors, helping them to understand your offering, the benefits of using your company and anticipating the questions that they’re most likely to ask.

Copywriting Pricing

Each copywriting project is quoted for individually, in order to represent best value and respond to each client’s specific needs.

We offer a wide range of copywriting services, so that you can pick and choose the elements you require according to the level of service you’re looking for. We can provide the following copywriting and SEO content services:

  • Website copywriting
  • SEO copywriting
  • Editing existing content
  • SEO copywriting for existing content

We can also proofread any content that you want to use, just to give it that final polish. Whatever your SEO or copywriting requirements, our professional copywriter and SEO expert is on hand to help.

Copywriting services your way

Whether you want a complete SEO and copywriting service, or would rather create your own content and then pass it to us to tweak, it’s entirely up to you. Our priority is to give you a website that you can be proud of, however you want it – so why not contact us now to find out more about our SEO copywriting solutions.

Web & Application Development in Leeds

Standard

Mobile Applications

We produce multiplatform apps – for iPhone, iPad, Android and Blackberry, at a highly competitive pricing structure. Our application prices start from only £995. Find out more.

Our Web Development Team

Our web development team has many web development skills covering:

  • ASP.NET Development
  • .NET WPF + Silverlight Development, WCF (Windows Communication Foundation)
  • Sharepoint, BizTalk Development
  • SQL Server, MySql, MS Access
  • Java EE Development
  • PHP Scripting
  • jQuery JavaScript
  • BlackBerry Applications
  • Android Applications
  • iPhone, Mac & iPad Application’s
  • C / C++ Programming
  • CMS (Content Management Systems including Drupal, WordPress, Joomla and many more…)
  • HTML 5 Design & Development
  • API’s, Parsing XML (Application Programming Interface’s)
  • Facebook Application’s
  • FBML (Facebook Markup Language)
  • Payment Gateways – PayPal, WorldPay, Barclays EPQD etc.

Contact us on 0113 287 1781 for more information on Web & Application Development.

jQuery sortable images – PHP display images in correct order

Standard

By using jQuery, PHP and MySQL you can create a clever an image sort script to allow users to choose the order of images in their advert for example.

Once you have your jQuery Sortable plug-in installed (available here: http://jqueryui.com/demos/sortable/) and it is successfully posting the image order to MySQL you can load that order and display the images in that order.

Step 1

First of all you need to find all images that match the id of the record you are currently looking at e.g. example.com/advert.php?cid=17 and call this ‘a’.

1
2
3
4
5
6
7
8
9
10
11
// Find all images relating to this item
$querya = "SELECT * FROM images WHERE cid ='$cid'";
$resulta = mysql_query($querya) or die(mysql_error());
 
$a = array(); // Define an Array
$i=0; // Start the image count at 0 so the first result equals 1
 
while($rowa=mysql_fetch_array($resulta)){ 
    $keya=$i++;
    $a[$keya] = $rowa['imgdata'];
}
// Find all images relating to this item
$querya = "SELECT * FROM images WHERE cid ='$cid'";
$resulta = mysql_query($querya) or die(mysql_error());

$a = array(); // Define an Array
$i=0; // Start the image count at 0 so the first result equals 1

while($rowa=mysql_fetch_array($resulta)){ 
    $keya=$i++;
    $a[$keya] = $rowa['imgdata'];
}

This will produce an array of image file names stored in the MySQL table with a corresponding number starting with 1.

Step 2

Next we need to find the image order for the current id of the record we are looking at. The image order should be saved in the MySQL table a comma separate list e.g. 3,1,4,2,5 so we must also explode this list too and call it ‘b’.

1
2
3
4
5
6
7
8
9
// Find order of images relating to this item
$queryb = "SELECT * FROM images_order WHERE cid = $cid";
$resultb = mysql_query($queryb) or die(mysql_error());
 
while($rowb = mysql_fetch_array($resultb)){
    $b = $rowb['order'];
}
 
$b = explode(',', $b);
// Find order of images relating to this item
$queryb = "SELECT * FROM images_order WHERE cid = $cid";
$resultb = mysql_query($queryb) or die(mysql_error());

while($rowb = mysql_fetch_array($resultb)){
	$b = $rowb['order'];
}

$b = explode(',', $b);

Step 3

Next we need to match the order of the images to the actual images for this item. So we first define a new array called ‘c’. Then we link the image order ‘b’ with the list of images in ‘a’. This will then display the images ‘a’ in the order specified in ‘b’.

1
2
3
4
5
6
// Match order of images to the actual images for this item
$c = array(); // Define an Array
 
foreach($b as $index) {
    $c[$index] = $a[$index];
}
// Match order of images to the actual images for this item
$c = array(); // Define an Array

foreach($b as $index) {
    $c[$index] = $a[$index];
}

Step 4

Now we have the images in the correct order ‘c’. We now need to display this to the user.

1
2
3
4
5
6
7
8
9
echo("<ul>");
 
foreach($b as $index) {
 
    echo("<li><img src='image-uploads/$a[$index]' /></li>");
 
}
 
echo("</ul>");
echo("<ul>");

foreach($b as $index) {

    echo("<li><img src='image-uploads/$a[$index]' /></li>");

}

echo("</ul>");

This will then display the images on the page in the correct order in a <ul> list.

If you have any questions about this script then please feel free to comment below.