Using Git

Wednesday, November 10th

Some very basic git commands. I don't use it a lot so don't always remember the commands I need.

Initialise a repository

Often I want to set up a main repository on my server that I can share amongst my other machines - so I can work on the laptop or the desktop machine (when James will let me use it). To do this you need to set up a bare repostitory.

git init --bare <repostitory name>


[don@@server] git init --bare theme/moko-papa/
Initialized empty Git repository in /srv/git/
[don@server]$ ll theme/moko-papa/
branches/    config       description  HEAD         hooks/       info/
        objects/     refs/

On the client, we need to clone the repository before we add to it.

don@client:~/Development/$ git clone don@server:/srv/git/ moko-papa
Cloning into 'moko-papa'...
warning: You appear to have cloned an empty repository.

Now we can add files to the folder, and add them to the git repository.

don@client:~/Development/    $
don@client:~/Development/$ cp -a moko-papa.bak/* moko-papa/
don@client:~/Development/$ cd moko-papa/
don@client:~/Development/$ git add *
don@client:~/Development/$ git commit -m "Inital commit of existing files"
 create mode 100644 templates/partials/social.html.twig
 create mode 100644 templates/partials/taxonomylist.html.twig
 create mode 100644 templates/simplesearch_results.html.twig
 create mode 100644 templates/snipcart.html.twig
 create mode 100644 thumbnail.jpg
don@client:~/Development/$ git push
Enumerating objects: 1993, done.
Counting objects: 100% (1993/1993), done.
Delta compression using up to 4 threads
Compressing objects: 100% (1984/1984), done.
Writing objects: 100% (1993/1993), 4.68 MiB | 6.40 MiB/s, done.
Total 1993 (delta 208), reused 0 (delta 0), pack-reused 0
To server:/srv/git/
 * [new branch]      master -> master
don@client:~/Development/$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

Now it is set up.

git add
git commit

On the server

git pull

Internet veteran, was a geek until it became cool, general technophile. Knows the difference between pressurised and pressured, possible and potential, etc.

Older Post Home Newer Post