File tree 1 file changed +74
-0
lines changed
1 file changed +74
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Day 8
2
+
3
+ Today we will learn to move around different branches.
4
+
5
+ ## Problem Statement:
6
+ One of your colleagues messed up here, and put the branches in the wrong timelines!<br >
7
+ You could delete and re-create these branches - but you can also directly move them to different commits, by using:
8
+ ``` bash
9
+ git checkout
10
+ ```
11
+
12
+ on the branch names, and then using:
13
+ ``` bash
14
+ git reset --hard
15
+ ```
16
+
17
+ on the commit where you want the branch to be.
18
+
19
+ The donut branch is in the right place, but the timeline is still incomplete - make you actually * eat* the donut in that branch!
20
+
21
+ ### Questions:
22
+ - Did you eat a baguette on the baguette branch?
23
+ - Did you drink a coffee on the coffee branch?
24
+ - Did you eat a donut on the donut branch?
25
+
26
+ <div align =" center " >
27
+ <img src =" https://github.com/ArnabKumarRoy02/Learn-git/assets/86621483/4fe7bebc-76b4-4776-b159-7537c34eb4e1 " width =450 >
28
+ <p >Diagram of the problem</p >
29
+ </div >
30
+
31
+ ## Solution
32
+
33
+ 1 . Checkout all the different branches and the file.
34
+ ``` bash
35
+ git checkout baguette
36
+ git checkout coffee
37
+ git checkout donut
38
+
39
+ # Check the file
40
+ nvim you.txt
41
+ ```
42
+
43
+ 2 . After checking the file, reset or delete the branch.
44
+ ``` bash
45
+ git branch -D baguette
46
+ git branch -D coffee
47
+ ```
48
+
49
+ 3 . Then go the respective position on where the actual branch should be there.
50
+ ``` bash
51
+ git checkout SHA Code
52
+
53
+ # Then create the branch that is required.
54
+ git branch baguette
55
+
56
+ # Again for branch - coffee
57
+ git checkout SHA Code
58
+ git branch coffee
59
+ ```
60
+
61
+ 4 . Go to the donut branch and make the changes.
62
+ ``` bash
63
+ git checkout donut
64
+
65
+ # Make the changes and commit
66
+ git add .
67
+ git commit -m " ate donut"
68
+ git push -u origin main
69
+ ```
70
+
71
+ <div align =" center " >
72
+ <img src =" https://github.com/ArnabKumarRoy02/Learn-git/assets/86621483/52dce6f1-7dfa-4f07-acdf-69296fd3afbb " width =450 >
73
+ <p >Diagram of the solution</p >
74
+ </div >
You can’t perform that action at this time.
0 commit comments