Skip to content

Instantly share code, notes, and snippets.

@oranblackwell
Last active August 29, 2015 14:02
Show Gist options
  • Save oranblackwell/83447ebb9df22f87479b to your computer and use it in GitHub Desktop.
Save oranblackwell/83447ebb9df22f87479b to your computer and use it in GitHub Desktop.
Simple Git Deployment using Tags

Simple Git Deployment using Tags

Example 1

Local

[ ~/Web/Sites/Example]$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   wp-content/themes/unite/single-events.php

no changes added to commit (use "git add" and/or "git commit -a")

[ ~/Web/Sites/Example]$ git commit -am "restructured single-events page as instructed. also fixed formatting."
[master 72b37f0] restructured single-events page as instructed. also fixed formatting.
 1 file changed, 29 insertions(+), 30 deletions(-)

[ ~/Web/Sites/Example]$ git tag
v1.0.0
v1.0.1
v1.1.0
v1.1.1
v2.0.0
v2.0.1
v2.0.2
v2.0.3
v2.1.0
v2.1.1

[ ~/Web/Sites/Example]$ git pull
Already up-to-date.

[ ~/Web/Sites/Example]$ git tag -a v2.1.2 -m v2.1.2

[ ~/Web/Sites/Example]$ git push && git push --tags
Counting objects: 11, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (6/6), 871 bytes | 0 bytes/s, done.
Total 6 (delta 3), reused 0 (delta 0)
To git@bitbucket.org:ebowdublin/feile.git
   78e59d8..72b37f0  master -> master
Counting objects: 1, done.
Writing objects: 100% (1/1), 162 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (delta 0)
To git@bitbucket.org:ebowdublin/feile.git
 * [new tag]         v2.1.2 -> v2.1.2

Remote

deploy@user:/var/www/vhosts/example.ie# git status
# Not currently on any branch.
nothing to commit (working directory clean)

deploy@user:/var/www/vhosts/example.ie# git describe --tags
v2.1.1

deploy@user:/var/www/vhosts/example.ie# git fetch --all
Fetching origin
remote: Counting objects: 53, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 7 (delta 3), reused 0 (delta 0)
Unpacking objects: 100% (7/7), done.
From bitbucket.org:ebowdublin/feile
   78e59d8..72b37f0  master     -> origin/master
 * [new tag]         v2.1.2     -> v2.1.2

deploy@user:/var/www/vhosts/example.ie# git checkout v2.1.2
Previous HEAD position was bad22fd... added wp-migrate db
HEAD is now at 72b37f0... restructured single-events page as instructed. also fixed formatting.

deploy@user:/var/www/vhosts/example.ie# git describe --tags
v2.1.2

Additional Deployment

Local

[ ~/Web/Sites/Example]$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   wp-content/themes/unite/header.php
	modified:   wp-content/themes/unite/index.php
	modified:   wp-content/themes/unite/single-events.php

no changes added to commit (use "git add" and/or "git commit -a")

[ ~/Web/Sites/Example]$ git commit -am "Fixed twitter url on other pages."
[master 9024014] Fixed twitter url on other pages.
 3 files changed, 40 insertions(+), 40 deletions(-)
[ ~/Web/Sites/Example]$ git tag
v1.0.0
v1.0.1
v1.1.0
v1.1.1
v2.0.0
v2.0.1
v2.0.2
v2.0.3
v2.1.0
v2.1.1
v2.1.2

[ ~/Web/Sites/Example]$ git tag -a v2.1.3 -m v2.1.3

[ ~/Web/Sites/Example]$ git push && git push --tags
Counting objects: 15, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (8/8), 861 bytes | 0 bytes/s, done.
Total 8 (delta 5), reused 0 (delta 0)
To git@bitbucket.org:ebowdublin/feile.git
   72b37f0..9024014  master -> master
Counting objects: 1, done.
Writing objects: 100% (1/1), 161 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (delta 0)
To git@bitbucket.org:ebowdublin/feile.git
 * [new tag]         v2.1.3 -> v2.1.3

Remote

 deploy@user:/var/www/vhosts/example.ie# git status
# Not currently on any branch.
nothing to commit (working directory clean)

deploy@user:/var/www/vhosts/example.ie# git fetch --all
Fetching origin
remote: Counting objects: 64, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 9 (delta 5), reused 0 (delta 0)
Unpacking objects: 100% (9/9), done.
From bitbucket.org:ebowdublin/feile
   72b37f0..9024014  master     -> origin/master
 * [new tag]         v2.1.3     -> v2.1.3

deploy@user:/var/www/vhosts/example.ie# git checkout v2.1.3
Previous HEAD position was 72b37f0... restructured single-events page as instructed. also fixed formatting.
HEAD is now at 9024014... Fixed twitter url on other pages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment