Advertisement
Guest User

Untitled

a guest
Sep 18th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.74 KB | None | 0 0
  1. root@tinkerbell:~/code# echo "meow" > file1
  2.  
  3. root@tinkerbell:~/code# echo "woem" > file2
  4.  
  5. root@tinkerbell:~/code# ls -al
  6. total 20
  7. drwxr-xr-x 3 root root 4096 Sep 18 11:27 .
  8. drwx------ 10 root root 4096 Sep 18 11:24 ..
  9. drwxr-xr-x 8 root root 4096 Sep 18 11:29 .git
  10. -rw-r--r-- 1 root root 5 Sep 18 11:27 file1
  11. -rw-r--r-- 1 root root 5 Sep 18 11:27 file2
  12.  
  13. root@tinkerbell:~/code# git add *
  14. git commit -m "added 2 files"
  15. [master f60c2d5] added 2 files
  16. Committer: Pink <root@tinkerbell.pink>
  17. 2 files changed, 2 insertions(+)
  18. create mode 100644 file1
  19. create mode 100644 file2
  20. root@tinkerbell:~/code# rm file2
  21.  
  22. root@tinkerbell:~/code# git status
  23. On branch master
  24. Changes not staged for commit:
  25. (use "git add/rm <file>..." to update what will be committed)
  26. (use "git checkout -- <file>..." to discard changes in working directory)
  27.  
  28. deleted: file2
  29.  
  30. root@tinkerbell:~/code# ls -al
  31. total 16
  32. drwxr-xr-x 3 root root 4096 Sep 18 11:17 .
  33. drwx------ 10 root root 4096 Sep 18 11:15 ..
  34. drwxr-xr-x 8 root root 4096 Sep 18 11:17 .git
  35. -rw-r--r-- 1 root root 5 Sep 18 11:17 file1
  36.  
  37. root@tinkerbell:~/code# git rm file1
  38. rm 'file1'
  39.  
  40. root@tinkerbell:~/code# ls -al
  41. total 12
  42. drwxr-xr-x 3 root root 4096 Sep 18 11:18 .
  43. drwx------ 10 root root 4096 Sep 18 11:15 ..
  44. drwxr-xr-x 8 root root 4096 Sep 18 11:18 .git
  45.  
  46. root@tinkerbell:~/code# git reset --hard HEAD
  47. HEAD is now at f60c2d5 added 2 files
  48.  
  49. root@tinkerbell:~/code# ls -al
  50. total 20
  51. drwxr-xr-x 3 root root 4096 Sep 18 11:19 .
  52. drwx------ 10 root root 4096 Sep 18 11:15 ..
  53. drwxr-xr-x 8 root root 4096 Sep 18 11:19 .git
  54. -rw-r--r-- 1 root root 5 Sep 18 11:19 file1
  55. -rw-r--r-- 1 root root 5 Sep 18 11:19 file2
  56.  
  57.  
  58. root@tinkerbell:~/code# git commit -m "Deleting this crap!"
  59. [master ce1e5f3] Deleting this crap!
  60. 2 files changed, 2 deletions(-)
  61. delete mode 100644 file1
  62. delete mode 100644 file2
  63.  
  64. root@tinkerbell:~/code# ls -al
  65. total 12
  66. drwxr-xr-x 3 root root 4096 Sep 18 11:20 .
  67. drwx------ 10 root root 4096 Sep 18 11:24 ..
  68. drwxr-xr-x 8 root root 4096 Sep 18 11:24 .git
  69.  
  70. root@tinkerbell:~/code# git log
  71. commit ce1e5f3ff695e01cd8ed529cfd2702c64fe4381e
  72. Author: Pink <root@localhost>
  73. Date: Fri Sep 18 11:24:15 2015 -0400
  74.  
  75. Deleting this crap!
  76.  
  77. commit f60c2d5e03ca3453c8a0a4bbc2d37108c8c1b37e
  78. Author: Pink <root@tinkerbell.pink>
  79. Date: Fri Sep 18 11:15:32 2015 -0400
  80.  
  81. added 2 files
  82.  
  83.  
  84.  
  85. root@tinkerbell:~/code# git checkout f60c2d5e03
  86. Note: checking out 'f60c2d5e03'.
  87.  
  88. You are in 'detached HEAD' state. You can look around, make experimental
  89. changes and commit them, and you can discard any commits you make in this
  90. state without impacting any branches by performing another checkout.
  91.  
  92. If you want to create a new branch to retain commits you create, you may
  93. do so (now or later) by using -b with the checkout command again. Example:
  94.  
  95. git checkout -b new_branch_name
  96.  
  97. HEAD is now at f60c2d5... added 2 files
  98. root@tinkerbell:~/code# ls -al
  99. total 20
  100. drwxr-xr-x 3 root root 4096 Sep 18 11:27 .
  101. drwx------ 10 root root 4096 Sep 18 11:24 ..
  102. drwxr-xr-x 8 root root 4096 Sep 18 11:27 .git
  103. -rw-r--r-- 1 root root 5 Sep 18 11:27 file1
  104. -rw-r--r-- 1 root root 5 Sep 18 11:27 file2
  105.  
  106. root@tinkerbell:~/code# git checkout f60c2d5e03 -b original_backup
  107. Switched to a new branch 'original_backup'
  108.  
  109. root@tinkerbell:~/code# ls -al
  110. total 20
  111. drwxr-xr-x 3 root root 4096 Sep 18 11:27 .
  112. drwx------ 10 root root 4096 Sep 18 11:24 ..
  113. drwxr-xr-x 8 root root 4096 Sep 18 11:29 .git
  114. -rw-r--r-- 1 root root 5 Sep 18 11:27 file1
  115. -rw-r--r-- 1 root root 5 Sep 18 11:27 file2
  116.  
  117. root@tinkerbell:~/code# git log
  118. commit f60c2d5e03ca3453c8a0a4bbc2d37108c8c1b37e
  119. Author: Pink <root@tinkerbell.pink>
  120. Date: Fri Sep 18 11:15:32 2015 -0400
  121.  
  122. added 2 files
  123.  
  124.  
  125. root@tinkerbell:~/code# git branch -l
  126. master
  127. * original_backup
  128.  
  129. root@tinkerbell:~/code# git checkout master
  130. Switched to branch 'master'
  131.  
  132. root@tinkerbell:~/code# ls -al
  133. total 12
  134. drwxr-xr-x 3 root root 4096 Sep 18 11:29 .
  135. drwx------ 10 root root 4096 Sep 18 11:24 ..
  136. drwxr-xr-x 8 root root 4096 Sep 18 11:29 .git
  137.  
  138. root@tinkerbell:~/code# git log
  139. commit ce1e5f3ff695e01cd8ed529cfd2702c64fe4381e
  140. Author: Pink <root@localhost>
  141. Date: Fri Sep 18 11:24:15 2015 -0400
  142.  
  143. Deleting this crap!
  144.  
  145. commit f60c2d5e03ca3453c8a0a4bbc2d37108c8c1b37e
  146. Author: Pink <root@tinkerbell.pink>
  147. Date: Fri Sep 18 11:15:32 2015 -0400
  148.  
  149. added 2 files
  150.  
  151. root@tinkerbell:~/code# echo "master branch file" >> master.branch
  152.  
  153. root@tinkerbell:~/code# ls -al
  154. total 16
  155. drwxr-xr-x 3 root root 4096 Sep 18 11:31 .
  156. drwx------ 10 root root 4096 Sep 18 11:24 ..
  157. drwxr-xr-x 8 root root 4096 Sep 18 11:29 .git
  158. -rw-r--r-- 1 root root 19 Sep 18 11:31 master.branch
  159.  
  160. root@tinkerbell:~/code# git add *
  161.  
  162. root@tinkerbell:~/code# git commit -m "master branch file added"
  163.  
  164. [master e06d148] master branch file added
  165. 1 file changed, 1 insertion(+)
  166. create mode 100644 master.branch
  167.  
  168. root@tinkerbell:~/code# git branch -l
  169. * master
  170. original_backup
  171.  
  172. root@tinkerbell:~/code# git log
  173. commit e06d14834bf76b8e66a81f0d5e09a770b98cb359
  174. Author: Pink <root@localhost>
  175. Date: Fri Sep 18 11:31:42 2015 -0400
  176.  
  177. master branch file added
  178.  
  179. commit ce1e5f3ff695e01cd8ed529cfd2702c64fe4381e
  180. Author: Pink <root@localhost>
  181. Date: Fri Sep 18 11:24:15 2015 -0400
  182.  
  183. Deleting this crap!
  184.  
  185. commit f60c2d5e03ca3453c8a0a4bbc2d37108c8c1b37e
  186. Author: Pink <root@tinkerbell.pink>
  187. Date: Fri Sep 18 11:15:32 2015 -0400
  188.  
  189. added 2 files
  190.  
  191. root@tinkerbell:~/code# git checkout original_backup
  192. Switched to branch 'original_backup'
  193.  
  194. root@tinkerbell:~/code# ls -al
  195. total 20
  196. drwxr-xr-x 3 root root 4096 Sep 18 11:32 .
  197. drwx------ 10 root root 4096 Sep 18 11:24 ..
  198. drwxr-xr-x 8 root root 4096 Sep 18 11:32 .git
  199. -rw-r--r-- 1 root root 5 Sep 18 11:32 file1
  200. -rw-r--r-- 1 root root 5 Sep 18 11:32 file2
  201.  
  202.  
  203. root@tinkerbell:~/code# git log
  204. commit f60c2d5e03ca3453c8a0a4bbc2d37108c8c1b37e
  205. Author: Pink <root@tinkerbell.pink>
  206. Date: Fri Sep 18 11:15:32 2015 -0400
  207.  
  208. added 2 files
  209. root@tinkerbell:~/code# echo "this is the original backup branch" >> backup.branch
  210.  
  211.  
  212. root@tinkerbell:~/code# ls -al
  213. total 24
  214. drwxr-xr-x 3 root root 4096 Sep 18 11:32 .
  215. drwx------ 10 root root 4096 Sep 18 11:24 ..
  216. drwxr-xr-x 8 root root 4096 Sep 18 11:32 .git
  217. -rw-r--r-- 1 root root 35 Sep 18 11:32 backup.branch
  218. -rw-r--r-- 1 root root 5 Sep 18 11:32 file1
  219. -rw-r--r-- 1 root root 5 Sep 18 11:32 file2
  220. root@tinkerbell:~/code# git add backup.branch
  221.  
  222.  
  223. root@tinkerbell:~/code# git commit -m "added file to backup branch"
  224. [original_backup e830b1f] added file to backup branch
  225. 1 file changed, 1 insertion(+)
  226. create mode 100644 backup.branch
  227.  
  228.  
  229. root@tinkerbell:~/code# git log
  230. commit e830b1fd2a8d04b771307d38a48b41b54eb160a8
  231. Author: Pink <root@localhost>
  232. Date: Fri Sep 18 11:33:16 2015 -0400
  233.  
  234. added file to backup branch
  235.  
  236. commit f60c2d5e03ca3453c8a0a4bbc2d37108c8c1b37e
  237. Author: Pink <root@tinkerbell.pink>
  238. Date: Fri Sep 18 11:15:32 2015 -0400
  239.  
  240. added 2 files
  241.  
  242.  
  243.  
  244. root@tinkerbell:~/code# vim script.sh
  245.  
  246. root@tinkerbell:~/code# ./script.sh asd
  247. This is a script
  248. supply second argument
  249. arg1: asd
  250. arg2:
  251.  
  252. root@tinkerbell:~/code# git add script.sh
  253. root@tinkerbell:~/code# git commit -m "added script.sh"
  254. [original_backup 435ea82] added script.sh
  255. 1 file changed, 14 insertions(+)
  256. create mode 100755 script.sh
  257.  
  258. ### Make changes to script.sh ###
  259.  
  260. root@tinkerbell:~/code# git diff
  261. diff --git a/script.sh b/script.sh
  262. index d9763fc..f746fd7 100755
  263. --- a/script.sh
  264. +++ b/script.sh
  265. @@ -6,8 +6,10 @@ arg2=$2
  266.  
  267. if [[ -z $arg1 ]]; then
  268. echo "supply first and second argument"
  269. + exit 1
  270. elif [[ -z $arg2 ]]; then
  271. echo "supply second argument"
  272. + exit 1
  273. fi
  274. echo "arg1: $arg1"
  275. echo "arg2: $arg2"
  276.  
  277. root@tinkerbell:~/code# git add script.sh
  278. root@tinkerbell:~/code# git commit -m "force script to return with exit code 1 if args are not supplied"
  279. [original_backup 2f799da] force script to return with exit code 1 if args are not supplied
  280. 1 file changed, 2 insertions(+)
  281.  
  282.  
  283. root@tinkerbell:~/code# git log
  284. commit 2f799dafe52b4a120ec286ac8344cc3a18bc3382
  285. Author: Pink <root@localhost>
  286. Date: Fri Sep 18 12:31:59 2015 -0400
  287.  
  288. force script to return with exit code 1 if args are not supplied
  289.  
  290. commit 435ea829efd77f1c76cce84675924ab523927daa
  291. Author: Pink <root@localhost>
  292. Date: Fri Sep 18 12:29:48 2015 -0400
  293.  
  294. added script.sh
  295.  
  296. commit e830b1fd2a8d04b771307d38a48b41b54eb160a8
  297. Author: Pink <root@localhost>
  298. Date: Fri Sep 18 11:33:16 2015 -0400
  299.  
  300. added file to backup branch
  301.  
  302. commit f60c2d5e03ca3453c8a0a4bbc2d37108c8c1b37e
  303. Author: Pink <root@tinkerbell.pink>
  304. Date: Fri Sep 18 11:15:32 2015 -0400
  305.  
  306. added 2 files
  307.  
  308. root@tinkerbell:~/code# git diff 2f799dafe52b4a120ec286ac8344cc3a18bc3382 f60c2d5e03ca3453c8a0a4bbc2d37108c8c1b37e -- ./
  309. diff --git a/backup.branch b/backup.branch
  310. deleted file mode 100644
  311. index 902e61f..0000000
  312. --- a/backup.branch
  313. +++ /dev/null
  314. @@ -1 +0,0 @@
  315. -this is the original backup branch
  316. diff --git a/script.sh b/script.sh
  317. deleted file mode 100755
  318. index f746fd7..0000000
  319. --- a/script.sh
  320. +++ /dev/null
  321. @@ -1,16 +0,0 @@
  322. -#!/bin/bash
  323. -
  324. -echo "This is a script"
  325. -arg1=$1
  326. -arg2=$2
  327. -
  328. -if [[ -z $arg1 ]]; then
  329. - echo "supply first and second argument"
  330. - exit 1
  331. -elif [[ -z $arg2 ]]; then
  332. - echo "supply second argument"
  333. - exit 1
  334. -fi
  335. -echo "arg1: $arg1"
  336. -echo "arg2: $arg2"
  337. -exit 0
  338.  
  339.  
  340. root@tinkerbell:~/code# git diff master...
  341. diff --git a/backup.branch b/backup.branch
  342. new file mode 100644
  343. index 0000000..902e61f
  344. --- /dev/null
  345. +++ b/backup.branch
  346. @@ -0,0 +1 @@
  347. +this is the original backup branch
  348. diff --git a/script.sh b/script.sh
  349. new file mode 100755
  350. index 0000000..f746fd7
  351. --- /dev/null
  352. +++ b/script.sh
  353. @@ -0,0 +1,16 @@
  354. +#!/bin/bash
  355. +
  356. +echo "This is a script"
  357. +arg1=$1
  358. +arg2=$2
  359. +
  360. +if [[ -z $arg1 ]]; then
  361. + echo "supply first and second argument"
  362. + exit 1
  363. +elif [[ -z $arg2 ]]; then
  364. + echo "supply second argument"
  365. + exit 1
  366. +fi
  367. +echo "arg1: $arg1"
  368. +echo "arg2: $arg2"
  369. +exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement