Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- root@tinkerbell:~/code# echo "meow" > file1
- root@tinkerbell:~/code# echo "woem" > file2
- root@tinkerbell:~/code# ls -al
- total 20
- drwxr-xr-x 3 root root 4096 Sep 18 11:27 .
- drwx------ 10 root root 4096 Sep 18 11:24 ..
- drwxr-xr-x 8 root root 4096 Sep 18 11:29 .git
- -rw-r--r-- 1 root root 5 Sep 18 11:27 file1
- -rw-r--r-- 1 root root 5 Sep 18 11:27 file2
- root@tinkerbell:~/code# git add *
- git commit -m "added 2 files"
- [master f60c2d5] added 2 files
- Committer: Pink <root@tinkerbell.pink>
- 2 files changed, 2 insertions(+)
- create mode 100644 file1
- create mode 100644 file2
- root@tinkerbell:~/code# rm file2
- root@tinkerbell:~/code# git status
- On branch master
- Changes not staged for commit:
- (use "git add/rm <file>..." to update what will be committed)
- (use "git checkout -- <file>..." to discard changes in working directory)
- deleted: file2
- root@tinkerbell:~/code# ls -al
- total 16
- drwxr-xr-x 3 root root 4096 Sep 18 11:17 .
- drwx------ 10 root root 4096 Sep 18 11:15 ..
- drwxr-xr-x 8 root root 4096 Sep 18 11:17 .git
- -rw-r--r-- 1 root root 5 Sep 18 11:17 file1
- root@tinkerbell:~/code# git rm file1
- rm 'file1'
- root@tinkerbell:~/code# ls -al
- total 12
- drwxr-xr-x 3 root root 4096 Sep 18 11:18 .
- drwx------ 10 root root 4096 Sep 18 11:15 ..
- drwxr-xr-x 8 root root 4096 Sep 18 11:18 .git
- root@tinkerbell:~/code# git reset --hard HEAD
- HEAD is now at f60c2d5 added 2 files
- root@tinkerbell:~/code# ls -al
- total 20
- drwxr-xr-x 3 root root 4096 Sep 18 11:19 .
- drwx------ 10 root root 4096 Sep 18 11:15 ..
- drwxr-xr-x 8 root root 4096 Sep 18 11:19 .git
- -rw-r--r-- 1 root root 5 Sep 18 11:19 file1
- -rw-r--r-- 1 root root 5 Sep 18 11:19 file2
- root@tinkerbell:~/code# git commit -m "Deleting this crap!"
- [master ce1e5f3] Deleting this crap!
- 2 files changed, 2 deletions(-)
- delete mode 100644 file1
- delete mode 100644 file2
- root@tinkerbell:~/code# ls -al
- total 12
- drwxr-xr-x 3 root root 4096 Sep 18 11:20 .
- drwx------ 10 root root 4096 Sep 18 11:24 ..
- drwxr-xr-x 8 root root 4096 Sep 18 11:24 .git
- root@tinkerbell:~/code# git log
- commit ce1e5f3ff695e01cd8ed529cfd2702c64fe4381e
- Author: Pink <root@localhost>
- Date: Fri Sep 18 11:24:15 2015 -0400
- Deleting this crap!
- commit f60c2d5e03ca3453c8a0a4bbc2d37108c8c1b37e
- Author: Pink <root@tinkerbell.pink>
- Date: Fri Sep 18 11:15:32 2015 -0400
- added 2 files
- root@tinkerbell:~/code# git checkout f60c2d5e03
- Note: checking out 'f60c2d5e03'.
- You are in 'detached HEAD' state. You can look around, make experimental
- changes and commit them, and you can discard any commits you make in this
- state without impacting any branches by performing another checkout.
- If you want to create a new branch to retain commits you create, you may
- do so (now or later) by using -b with the checkout command again. Example:
- git checkout -b new_branch_name
- HEAD is now at f60c2d5... added 2 files
- root@tinkerbell:~/code# ls -al
- total 20
- drwxr-xr-x 3 root root 4096 Sep 18 11:27 .
- drwx------ 10 root root 4096 Sep 18 11:24 ..
- drwxr-xr-x 8 root root 4096 Sep 18 11:27 .git
- -rw-r--r-- 1 root root 5 Sep 18 11:27 file1
- -rw-r--r-- 1 root root 5 Sep 18 11:27 file2
- root@tinkerbell:~/code# git checkout f60c2d5e03 -b original_backup
- Switched to a new branch 'original_backup'
- root@tinkerbell:~/code# ls -al
- total 20
- drwxr-xr-x 3 root root 4096 Sep 18 11:27 .
- drwx------ 10 root root 4096 Sep 18 11:24 ..
- drwxr-xr-x 8 root root 4096 Sep 18 11:29 .git
- -rw-r--r-- 1 root root 5 Sep 18 11:27 file1
- -rw-r--r-- 1 root root 5 Sep 18 11:27 file2
- root@tinkerbell:~/code# git log
- commit f60c2d5e03ca3453c8a0a4bbc2d37108c8c1b37e
- Author: Pink <root@tinkerbell.pink>
- Date: Fri Sep 18 11:15:32 2015 -0400
- added 2 files
- root@tinkerbell:~/code# git branch -l
- master
- * original_backup
- root@tinkerbell:~/code# git checkout master
- Switched to branch 'master'
- root@tinkerbell:~/code# ls -al
- total 12
- drwxr-xr-x 3 root root 4096 Sep 18 11:29 .
- drwx------ 10 root root 4096 Sep 18 11:24 ..
- drwxr-xr-x 8 root root 4096 Sep 18 11:29 .git
- root@tinkerbell:~/code# git log
- commit ce1e5f3ff695e01cd8ed529cfd2702c64fe4381e
- Author: Pink <root@localhost>
- Date: Fri Sep 18 11:24:15 2015 -0400
- Deleting this crap!
- commit f60c2d5e03ca3453c8a0a4bbc2d37108c8c1b37e
- Author: Pink <root@tinkerbell.pink>
- Date: Fri Sep 18 11:15:32 2015 -0400
- added 2 files
- root@tinkerbell:~/code# echo "master branch file" >> master.branch
- root@tinkerbell:~/code# ls -al
- total 16
- drwxr-xr-x 3 root root 4096 Sep 18 11:31 .
- drwx------ 10 root root 4096 Sep 18 11:24 ..
- drwxr-xr-x 8 root root 4096 Sep 18 11:29 .git
- -rw-r--r-- 1 root root 19 Sep 18 11:31 master.branch
- root@tinkerbell:~/code# git add *
- root@tinkerbell:~/code# git commit -m "master branch file added"
- [master e06d148] master branch file added
- 1 file changed, 1 insertion(+)
- create mode 100644 master.branch
- root@tinkerbell:~/code# git branch -l
- * master
- original_backup
- root@tinkerbell:~/code# git log
- commit e06d14834bf76b8e66a81f0d5e09a770b98cb359
- Author: Pink <root@localhost>
- Date: Fri Sep 18 11:31:42 2015 -0400
- master branch file added
- commit ce1e5f3ff695e01cd8ed529cfd2702c64fe4381e
- Author: Pink <root@localhost>
- Date: Fri Sep 18 11:24:15 2015 -0400
- Deleting this crap!
- commit f60c2d5e03ca3453c8a0a4bbc2d37108c8c1b37e
- Author: Pink <root@tinkerbell.pink>
- Date: Fri Sep 18 11:15:32 2015 -0400
- added 2 files
- root@tinkerbell:~/code# git checkout original_backup
- Switched to branch 'original_backup'
- root@tinkerbell:~/code# ls -al
- total 20
- drwxr-xr-x 3 root root 4096 Sep 18 11:32 .
- drwx------ 10 root root 4096 Sep 18 11:24 ..
- drwxr-xr-x 8 root root 4096 Sep 18 11:32 .git
- -rw-r--r-- 1 root root 5 Sep 18 11:32 file1
- -rw-r--r-- 1 root root 5 Sep 18 11:32 file2
- root@tinkerbell:~/code# git log
- commit f60c2d5e03ca3453c8a0a4bbc2d37108c8c1b37e
- Author: Pink <root@tinkerbell.pink>
- Date: Fri Sep 18 11:15:32 2015 -0400
- added 2 files
- root@tinkerbell:~/code# echo "this is the original backup branch" >> backup.branch
- root@tinkerbell:~/code# ls -al
- total 24
- drwxr-xr-x 3 root root 4096 Sep 18 11:32 .
- drwx------ 10 root root 4096 Sep 18 11:24 ..
- drwxr-xr-x 8 root root 4096 Sep 18 11:32 .git
- -rw-r--r-- 1 root root 35 Sep 18 11:32 backup.branch
- -rw-r--r-- 1 root root 5 Sep 18 11:32 file1
- -rw-r--r-- 1 root root 5 Sep 18 11:32 file2
- root@tinkerbell:~/code# git add backup.branch
- root@tinkerbell:~/code# git commit -m "added file to backup branch"
- [original_backup e830b1f] added file to backup branch
- 1 file changed, 1 insertion(+)
- create mode 100644 backup.branch
- root@tinkerbell:~/code# git log
- commit e830b1fd2a8d04b771307d38a48b41b54eb160a8
- Author: Pink <root@localhost>
- Date: Fri Sep 18 11:33:16 2015 -0400
- added file to backup branch
- commit f60c2d5e03ca3453c8a0a4bbc2d37108c8c1b37e
- Author: Pink <root@tinkerbell.pink>
- Date: Fri Sep 18 11:15:32 2015 -0400
- added 2 files
- root@tinkerbell:~/code# vim script.sh
- root@tinkerbell:~/code# ./script.sh asd
- This is a script
- supply second argument
- arg1: asd
- arg2:
- root@tinkerbell:~/code# git add script.sh
- root@tinkerbell:~/code# git commit -m "added script.sh"
- [original_backup 435ea82] added script.sh
- 1 file changed, 14 insertions(+)
- create mode 100755 script.sh
- ### Make changes to script.sh ###
- root@tinkerbell:~/code# git diff
- diff --git a/script.sh b/script.sh
- index d9763fc..f746fd7 100755
- --- a/script.sh
- +++ b/script.sh
- @@ -6,8 +6,10 @@ arg2=$2
- if [[ -z $arg1 ]]; then
- echo "supply first and second argument"
- + exit 1
- elif [[ -z $arg2 ]]; then
- echo "supply second argument"
- + exit 1
- fi
- echo "arg1: $arg1"
- echo "arg2: $arg2"
- root@tinkerbell:~/code# git add script.sh
- root@tinkerbell:~/code# git commit -m "force script to return with exit code 1 if args are not supplied"
- [original_backup 2f799da] force script to return with exit code 1 if args are not supplied
- 1 file changed, 2 insertions(+)
- root@tinkerbell:~/code# git log
- commit 2f799dafe52b4a120ec286ac8344cc3a18bc3382
- Author: Pink <root@localhost>
- Date: Fri Sep 18 12:31:59 2015 -0400
- force script to return with exit code 1 if args are not supplied
- commit 435ea829efd77f1c76cce84675924ab523927daa
- Author: Pink <root@localhost>
- Date: Fri Sep 18 12:29:48 2015 -0400
- added script.sh
- commit e830b1fd2a8d04b771307d38a48b41b54eb160a8
- Author: Pink <root@localhost>
- Date: Fri Sep 18 11:33:16 2015 -0400
- added file to backup branch
- commit f60c2d5e03ca3453c8a0a4bbc2d37108c8c1b37e
- Author: Pink <root@tinkerbell.pink>
- Date: Fri Sep 18 11:15:32 2015 -0400
- added 2 files
- root@tinkerbell:~/code# git diff 2f799dafe52b4a120ec286ac8344cc3a18bc3382 f60c2d5e03ca3453c8a0a4bbc2d37108c8c1b37e -- ./
- diff --git a/backup.branch b/backup.branch
- deleted file mode 100644
- index 902e61f..0000000
- --- a/backup.branch
- +++ /dev/null
- @@ -1 +0,0 @@
- -this is the original backup branch
- diff --git a/script.sh b/script.sh
- deleted file mode 100755
- index f746fd7..0000000
- --- a/script.sh
- +++ /dev/null
- @@ -1,16 +0,0 @@
- -#!/bin/bash
- -
- -echo "This is a script"
- -arg1=$1
- -arg2=$2
- -
- -if [[ -z $arg1 ]]; then
- - echo "supply first and second argument"
- - exit 1
- -elif [[ -z $arg2 ]]; then
- - echo "supply second argument"
- - exit 1
- -fi
- -echo "arg1: $arg1"
- -echo "arg2: $arg2"
- -exit 0
- root@tinkerbell:~/code# git diff master...
- diff --git a/backup.branch b/backup.branch
- new file mode 100644
- index 0000000..902e61f
- --- /dev/null
- +++ b/backup.branch
- @@ -0,0 +1 @@
- +this is the original backup branch
- diff --git a/script.sh b/script.sh
- new file mode 100755
- index 0000000..f746fd7
- --- /dev/null
- +++ b/script.sh
- @@ -0,0 +1,16 @@
- +#!/bin/bash
- +
- +echo "This is a script"
- +arg1=$1
- +arg2=$2
- +
- +if [[ -z $arg1 ]]; then
- + echo "supply first and second argument"
- + exit 1
- +elif [[ -z $arg2 ]]; then
- + echo "supply second argument"
- + exit 1
- +fi
- +echo "arg1: $arg1"
- +echo "arg2: $arg2"
- +exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement