You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

426 lines
15 KiB

  1. fdai7755@pc13:~$ cd
  2. fdai7755@pc13:~$ ls
  3. Desktop Downloads Music Public Videos
  4. Documents Lerntagebuch Pictures Templates
  5. fdai7755@pc13:~$ mkdir uebung_git
  6. fdai7755@pc13:~$ cd uebung_git/
  7. fdai7755@pc13:~/uebung_git$ git init local_repository
  8. hint: Using 'master' as the name for the initial branch. This default branch name
  9. hint: is subject to change. To configure the initial branch name to use in all
  10. hint: of your new repositories, which will suppress this warning, call:
  11. hint:
  12. hint: git config --global init.defaultBranch <name>
  13. hint:
  14. hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
  15. hint: 'development'. The just-created branch can be renamed via this command:
  16. hint:
  17. hint: git branch -m <name>
  18. Initialized empty Git repository in /home/fdai7755/uebung_git/local_repository/.git/
  19. fdai7755@pc13:~/uebung_git$ ls
  20. local_repository
  21. fdai7755@pc13:~/uebung_git$ git init.defaultBranch master
  22. git: 'init.defaultBranch' is not a git command. See 'git --help'.
  23. fdai7755@pc13:~/uebung_git$ git config --global init.defaultBranch master
  24. fdai7755@pc13:~/uebung_git$ cd local_repository/
  25. fdai7755@pc13:~/uebung_git/local_repository$ ls
  26. fdai7755@pc13:~/uebung_git/local_repository$ ls -l
  27. total 0
  28. fdai7755@pc13:~/uebung_git/local_repository$ ls -a
  29. . .. .git
  30. fdai7755@pc13:~/uebung_git/local_repository$ echo eins >> beispiel.txt
  31. fdai7755@pc13:~/uebung_git/local_repository$ echo zwei >> beispiel.txt
  32. fdai7755@pc13:~/uebung_git/local_repository$ echo drei >> beispiel.txt
  33. fdai7755@pc13:~/uebung_git/local_repository$ echo vier >> beispiel.txt
  34. fdai7755@pc13:~/uebung_git/local_repository$ ls
  35. beispiel.txt
  36. fdai7755@pc13:~/uebung_git/local_repository$ echo beispiel.txt
  37. beispiel.txt
  38. fdai7755@pc13:~/uebung_git/local_repository$ echo || less beispiel.txt
  39. fdai7755@pc13:~/uebung_git/local_repository$ echo | less beispiel.txt
  40. fdai7755@pc13:~/uebung_git/local_repository$ cat beispiel.txt
  41. eins
  42. zwei
  43. drei
  44. vier
  45. fdai7755@pc13:~/uebung_git/local_repository$ git status
  46. On branch master
  47. No commits yet
  48. Untracked files:
  49. (use "git add <file>..." to include in what will be committed)
  50. beispiel.txt
  51. nothing added to commit but untracked files present (use "git add" to track)
  52. fdai7755@pc13:~/uebung_git/local_repository$ git add beispiel.txt
  53. fdai7755@pc13:~/uebung_git/local_repository$ git commit -m "initialer commit"
  54. [master (root-commit) 376ebd1] initialer commit
  55. 1 file changed, 4 insertions(+)
  56. create mode 100644 beispiel.txt
  57. fdai7755@pc13:~/uebung_git/local_repository$ echo fünf >> beispiel.txt
  58. fdai7755@pc13:~/uebung_git/local_repository$ echo sechs >> beispiel.txt
  59. fdai7755@pc13:~/uebung_git/local_repository$ echo sieben >> beispiel.txt
  60. fdai7755@pc13:~/uebung_git/local_repository$ echo acht >> beispiel.txt
  61. fdai7755@pc13:~/uebung_git/local_repository$ echo neun >> beispiel.txt
  62. fdai7755@pc13:~/uebung_git/local_repository$ cat beispiel.txt
  63. eins
  64. zwei
  65. drei
  66. vier
  67. fünf
  68. sechs
  69. sieben
  70. acht
  71. neun
  72. fdai7755@pc13:~/uebung_git/local_repository$ nano beispiel.txt
  73. fdai7755@pc13:~/uebung_git/local_repository$ cat beispiel.txt
  74. eins
  75. zwei
  76. drei
  77. vier
  78. fünf
  79. sechs
  80. sieben
  81. acht
  82. neun
  83. Hallo
  84. ich bins
  85. fdai7755@pc13:~/uebung_git/local_repository$ git status
  86. On branch master
  87. Changes not staged for commit:
  88. (use "git add <file>..." to update what will be committed)
  89. (use "git restore <file>..." to discard changes in working directory)
  90. modified: beispiel.txt
  91. no changes added to commit (use "git add" and/or "git commit -a")
  92. fdai7755@pc13:~/uebung_git/local_repository$ git add beispiel.txt
  93. fdai7755@pc13:~/uebung_git/local_repository$ git status
  94. On branch master
  95. Changes to be committed:
  96. (use "git restore --staged <file>..." to unstage)
  97. modified: beispiel.txt
  98. fdai7755@pc13:~/uebung_git/local_repository$ git commit -m "neue Wörter hinzugefügt"
  99. [master 85c669d] neue Wörter hinzugefügt
  100. 1 file changed, 7 insertions(+)
  101. fdai7755@pc13:~/uebung_git/local_repository$ git --help
  102. usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
  103. [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
  104. [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
  105. [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
  106. [--super-prefix=<path>] [--config-env=<name>=<envvar>]
  107. <command> [<args>]
  108. These are common Git commands used in various situations:
  109. start a working area (see also: git help tutorial)
  110. clone Clone a repository into a new directory
  111. init Create an empty Git repository or reinitialize an existing one
  112. work on the current change (see also: git help everyday)
  113. add Add file contents to the index
  114. mv Move or rename a file, a directory, or a symlink
  115. restore Restore working tree files
  116. rm Remove files from the working tree and from the index
  117. examine the history and state (see also: git help revisions)
  118. bisect Use binary search to find the commit that introduced a bug
  119. diff Show changes between commits, commit and working tree, etc
  120. grep Print lines matching a pattern
  121. log Show commit logs
  122. show Show various types of objects
  123. status Show the working tree status
  124. grow, mark and tweak your common history
  125. branch List, create, or delete branches
  126. commit Record changes to the repository
  127. merge Join two or more development histories together
  128. rebase Reapply commits on top of another base tip
  129. reset Reset current HEAD to the specified state
  130. switch Switch branches
  131. tag Create, list, delete or verify a tag object signed with GPG
  132. collaborate (see also: git help workflows)
  133. fetch Download objects and refs from another repository
  134. pull Fetch from and integrate with another repository or a local branch
  135. push Update remote refs along with associated objects
  136. 'git help -a' and 'git help -g' list available subcommands and some
  137. concept guides. See 'git help <command>' or 'git help <concept>'
  138. to read about a specific subcommand or concept.
  139. See 'git help git' for an overview of the system.
  140. fdai7755@pc13:~/uebung_git/local_repository$ git log
  141. commit 85c669d265b90b546ca6535f0fa367329ebc6be8 (HEAD -> master)
  142. Author: fdai7755 <georg.volkmar1@informatik.hs-fulda.de>
  143. Date: Thu Nov 16 14:07:40 2023 +0100
  144. neue Wörter hinzugefügt
  145. commit 376ebd1b28468396bcf636856a4175678514aadd
  146. Author: fdai7755 <georg.volkmar1@informatik.hs-fulda.de>
  147. Date: Thu Nov 16 14:03:09 2023 +0100
  148. initialer commit
  149. fdai7755@pc13:~/uebung_git/local_repository$ git log --oneline
  150. 85c669d (HEAD -> master) neue Wörter hinzugefügt
  151. 376ebd1 initialer commit
  152. fdai7755@pc13:~/uebung_git/local_repository$ git log --oneline --graph
  153. * 85c669d (HEAD -> master) neue Wörter hinzugefügt
  154. * 376ebd1 initialer commit
  155. fdai7755@pc13:~/uebung_git/local_repository$ nano beispiel.txt
  156. fdai7755@pc13:~/uebung_git/local_repository$ git div
  157. git: 'div' is not a git command. See 'git --help'.
  158. The most similar command is
  159. diff
  160. fdai7755@pc13:~/uebung_git/local_repository$ git div beispiel.txt
  161. git: 'div' is not a git command. See 'git --help'.
  162. The most similar command is
  163. diff
  164. fdai7755@pc13:~/uebung_git/local_repository$ git diff beispiel.txt
  165. diff --git a/beispiel.txt b/beispiel.txt
  166. index 0ec0bfe..21323c2 100644
  167. --- a/beispiel.txt
  168. +++ b/beispiel.txt
  169. @@ -1,8 +1,8 @@
  170. eins
  171. zwei
  172. -drei
  173. +3
  174. vier
  175. -fünf
  176. +5
  177. sechs
  178. sieben
  179. acht
  180. fdai7755@pc13:~/uebung_git/local_repository$ git add -i
  181. staged unstaged path
  182. 1: unchanged +2/-2 beispiel.txt
  183. *** Commands ***
  184. 1: status 2: update 3: revert 4: add untracked
  185. 5: patch 6: diff 7: quit 8: help
  186. What now> u
  187. staged unstaged path
  188. 1: unchanged +2/-2 beispiel.txt
  189. Update>> 1
  190. staged unstaged path
  191. * 1: unchanged +2/-2 beispiel.txt
  192. Update>>
  193. updated 1 path
  194. *** Commands ***
  195. 1: status 2: update 3: revert 4: add untracked
  196. 5: patch 6: diff 7: quit 8: help
  197. What now> q
  198. Bye.
  199. fdai7755@pc13:~/uebung_git/local_repository$ git status
  200. On branch master
  201. Changes to be committed:
  202. (use "git restore --staged <file>..." to unstage)
  203. modified: beispiel.txt
  204. fdai7755@pc13:~/uebung_git/local_repository$ git gui
  205. fdai7755@pc13:~/uebung_git/local_repository$ git status
  206. On branch master
  207. Changes to be committed:
  208. (use "git restore --staged <file>..." to unstage)
  209. modified: beispiel.txt
  210. fdai7755@pc13:~/uebung_git/local_repository$ git commit -m "partielle Änderung"
  211. [master 7e0df0a] partielle Änderung
  212. 1 file changed, 2 insertions(+), 2 deletions(-)
  213. fdai7755@pc13:~/uebung_git/local_repository$ git stauts
  214. git: 'stauts' is not a git command. See 'git --help'.
  215. The most similar command is
  216. status
  217. fdai7755@pc13:~/uebung_git/local_repository$ git stats
  218. git: 'stats' is not a git command. See 'git --help'.
  219. The most similar command is
  220. status
  221. fdai7755@pc13:~/uebung_git/local_repository$ git status
  222. On branch master
  223. nothing to commit, working tree clean
  224. fdai7755@pc13:~/uebung_git/local_repository$ git diff
  225. fdai7755@pc13:~/uebung_git/local_repository$ git diff
  226. diff --git a/beispiel.txt b/beispiel.txt
  227. index 21323c2..9791872 100644
  228. --- a/beispiel.txt
  229. +++ b/beispiel.txt
  230. @@ -9,3 +9,5 @@ acht
  231. neun
  232. Hallo
  233. ich bins
  234. +hey
  235. +hey
  236. fdai7755@pc13:~/uebung_git/local_repository$ git reset beispiel.txt
  237. Unstaged changes after reset:
  238. M beispiel.txt
  239. fdai7755@pc13:~/uebung_git/local_repository$ git diff
  240. diff --git a/beispiel.txt b/beispiel.txt
  241. index 21323c2..9791872 100644
  242. --- a/beispiel.txt
  243. +++ b/beispiel.txt
  244. @@ -9,3 +9,5 @@ acht
  245. neun
  246. Hallo
  247. ich bins
  248. +hey
  249. +hey
  250. fdai7755@pc13:~/uebung_git/local_repository$ git restore beispiel.txt
  251. fdai7755@pc13:~/uebung_git/local_repository$ git diff
  252. fdai7755@pc13:~/uebung_git/local_repository$ git checkout
  253. fdai7755@pc13:~/uebung_git/local_repository$ git diff
  254. fdai7755@pc13:~/uebung_git/local_repository$ git checkout -b test1
  255. Switched to a new branch 'test1'
  256. fdai7755@pc13:~/uebung_git/local_repository$ git status
  257. On branch test1
  258. nothing to commit, working tree clean
  259. fdai7755@pc13:~/uebung_git/local_repository$ git log --oneline --graph --all
  260. * 7e0df0a (HEAD -> test1, master) partielle Änderung
  261. * 85c669d neue Wörter hinzugefügt
  262. * 376ebd1 initialer commit
  263. fdai7755@pc13:~/uebung_git/local_repository$ git add beispiel.txt && git commit -m "änderungen in Zweig 1"
  264. [test1 f1e76f3] änderungen in Zweig 1
  265. 1 file changed, 6 insertions(+)
  266. fdai7755@pc13:~/uebung_git/local_repository$ git log --oneline --graph --all
  267. * f1e76f3 (HEAD -> test1) änderungen in Zweig 1
  268. * 7e0df0a (master) partielle Änderung
  269. * 85c669d neue Wörter hinzugefügt
  270. * 376ebd1 initialer commit
  271. fdai7755@pc13:~/uebung_git/local_repository$ git ui
  272. git: 'ui' is not a git command. See 'git --help'.
  273. The most similar command is
  274. gui
  275. fdai7755@pc13:~/uebung_git/local_repository$ git gui
  276. ^C
  277. fdai7755@pc13:~/uebung_git/local_repository$ git switch master
  278. Switched to branch 'master'
  279. fdai7755@pc13:~/uebung_git/local_repository$ git checkout -b test2
  280. Switched to a new branch 'test2'
  281. fdai7755@pc13:~/uebung_git/local_repository$ git switch test2
  282. Already on 'test2'
  283. fdai7755@pc13:~/uebung_git/local_repository$ git add beispiel.txt
  284. fdai7755@pc13:~/uebung_git/local_repository$ git commit -m "änderung in Zweig2"
  285. [test2 44e26a2] änderung in Zweig2
  286. 1 file changed, 4 insertions(+)
  287. fdai7755@pc13:~/uebung_git/local_repository$ git log --oneline --graph --all
  288. * 44e26a2 (HEAD -> test2) änderung in Zweig2
  289. | * f1e76f3 (test1) änderungen in Zweig 1
  290. |/
  291. * 7e0df0a (master) partielle Änderung
  292. * 85c669d neue Wörter hinzugefügt
  293. * 376ebd1 initialer commit
  294. fdai7755@pc13:~/uebung_git/local_repository$ git gui
  295. ^C
  296. fdai7755@pc13:~/uebung_git/local_repository$ git log --oneline --graph
  297. * 44e26a2 (HEAD -> test2) änderung in Zweig2
  298. * 7e0df0a (master) partielle Änderung
  299. * 85c669d neue Wörter hinzugefügt
  300. * 376ebd1 initialer commit
  301. fdai7755@pc13:~/uebung_git/local_repository$ git merge test1
  302. Auto-merging beispiel.txt
  303. CONFLICT (content): Merge conflict in beispiel.txt
  304. Automatic merge failed; fix conflicts and then commit the result.
  305. fdai7755@pc13:~/uebung_git/local_repository$ git add beispiel.txt
  306. fdai7755@pc13:~/uebung_git/local_repository$ git status
  307. On branch test2
  308. All conflicts fixed but you are still merging.
  309. (use "git commit" to conclude merge)
  310. Changes to be committed:
  311. modified: beispiel.txt
  312. fdai7755@pc13:~/uebung_git/local_repository$ git commit
  313. [test2 b41571e] Merge branch 'test1' into test2
  314. fdai7755@pc13:~/uebung_git/local_repository$ git log
  315. commit b41571ef7e6313f74f445cad165d778906dc0155 (HEAD -> test2)
  316. Merge: 44e26a2 f1e76f3
  317. Author: fdai7755 <georg.volkmar1@informatik.hs-fulda.de>
  318. Date: Thu Nov 16 14:47:07 2023 +0100
  319. Merge branch 'test1' into test2
  320. commit 44e26a26233a843c432a3c1d20c619aeba845ca6
  321. Author: fdai7755 <georg.volkmar1@informatik.hs-fulda.de>
  322. Date: Thu Nov 16 14:40:39 2023 +0100
  323. änderung in Zweig2
  324. commit f1e76f3835c59dcf7b6d304f5182512a49e360bc (test1)
  325. Author: fdai7755 <georg.volkmar1@informatik.hs-fulda.de>
  326. Date: Thu Nov 16 14:32:49 2023 +0100
  327. änderungen in Zweig 1
  328. commit 7e0df0a07b9c2b1e71a0b76bf2555273334676b3 (master)
  329. Author: fdai7755 <georg.volkmar1@informatik.hs-fulda.de>
  330. Date: Thu Nov 16 14:22:48 2023 +0100
  331. fdai7755@pc13:~/uebung_git/local_repository$ git log --oneline --graph
  332. * b41571e (HEAD -> test2) Merge branch 'test1' into test2
  333. |\
  334. | * f1e76f3 (test1) änderungen in Zweig 1
  335. * | 44e26a2 änderung in Zweig2
  336. |/
  337. * 7e0df0a (master) partielle Änderung
  338. * 85c669d neue Wörter hinzugefügt
  339. * 376ebd1 initialer commit
  340. fdai7755@pc13:~/uebung_git/local_repository$ ^C
  341. fdai7755@pc13:~/uebung_git/local_repository$ git reset 44e26a2
  342. Unstaged changes after reset:
  343. M beispiel.txt
  344. fdai7755@pc13:~/uebung_git/local_repository$ git status
  345. On branch test2
  346. Changes not staged for commit:
  347. (use "git add <file>..." to update what will be committed)
  348. (use "git restore <file>..." to discard changes in working directory)
  349. modified: beispiel.txt
  350. no changes added to commit (use "git add" and/or "git commit -a")
  351. fdai7755@pc13:~/uebung_git/local_repository$ git reset --hard
  352. HEAD is now at 44e26a2 änderung in Zweig2
  353. fdai7755@pc13:~/uebung_git/local_repository$ git log --oneline --graph --all
  354. * 44e26a2 (HEAD -> test2) änderung in Zweig2
  355. | * f1e76f3 (test1) änderungen in Zweig 1
  356. |/
  357. * 7e0df0a (master) partielle Änderung
  358. * 85c669d neue Wörter hinzugefügt
  359. * 376ebd1 initialer commit
  360. fdai7755@pc13:~/uebung_git/local_repository$ git switch test1
  361. Switched to branch 'test1'
  362. fdai7755@pc13:~/uebung_git/local_repository$ git merge test2
  363. Auto-merging beispiel.txt
  364. CONFLICT (content): Merge conflict in beispiel.txt
  365. Automatic merge failed; fix conflicts and then commit the result.
  366. fdai7755@pc13:~/uebung_git/local_repository$ git merge --abort
  367. fdai7755@pc13:~/uebung_git/local_repository$ git status
  368. On branch test1
  369. nothing to commit, working tree clean
  370. fdai7755@pc13:~/uebung_git/local_repository$ git merge test2
  371. Auto-merging beispiel.txt
  372. CONFLICT (content): Merge conflict in beispiel.txt
  373. Automatic merge failed; fix conflicts and then commit the result.
  374. fdai7755@pc13:~/uebung_git/local_repository$ git add beispiel.txt
  375. fdai7755@pc13:~/uebung_git/local_repository$ git status
  376. On branch test1
  377. All conflicts fixed but you are still merging.
  378. (use "git commit" to conclude merge)
  379. Changes to be committed:
  380. modified: beispiel.txt
  381. fdai7755@pc13:~/uebung_git/local_repository$ git commit
  382. [test1 32c26f9] Merge branch 'test2' into test1
  383. fdai7755@pc13:~/uebung_git/local_repository$ git status
  384. On branch test1
  385. nothing to commit, working tree clean
  386. fdai7755@pc13:~/uebung_git/local_repository$ git switch master
  387. Switched to branch 'master'
  388. fdai7755@pc13:~/uebung_git/local_repository$