-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-rebase.html
More file actions
173 lines (130 loc) · 6.79 KB
/
Copy pathgit-rebase.html
File metadata and controls
173 lines (130 loc) · 6.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Git Test</title>
</head>
<style>
.aTagStyle{
border: 1px solid red;
padding: 8px;
color: rgb(179, 138, 64);
}
.randomResource li a{
color: rgb(179, 138, 64);
}
.randomResource li{
margin-bottom: 9px;
}
</style>
<body style="background-color: black; color: white;">
<h1 style="text-align: center;">Git Test (Rebase)</h1>
<a href="https://github.com/Shahed-Chy-Suzan/git-test" target="_blank" rel="noopener" class="aTagStyle">Repository Link: Git Test (Rebase)</a>
<a href="https://docs.google.com/document/d/1MESO-7ETPdW2ALj5FTlOJFQhruebnsXzSuUInidezhk/edit" target="_blank" rel="noopener" class="aTagStyle">Blog-Git Interactive Rebase</a>
<hr style="margin-top: 33px;">
<!-- --------------------------------------------------------------------------------------------- -->
<!-- Git Amend -->
<!-- --------------------------------------------------------------------------------------------- -->
<h2>Git Amend</h2>
<p>commit 1</p>
<p>commit 2</p>
<p>git amend</p>
<p>git amend (git commit --amend /force_push)</p>
<p>
<pre>
-- The `git commit --amend` command in Git is used to modify the most recent commit. This is particularly useful when you want to:
- Change the commit message of the latest commit.
- Add or remove files from the latest commit.
- Combine staged changes with the previous commit.
-- git commit --amend //This will open your default text editor where you can edit the commit message.
--
-- git commit --amend -m "Initial commit with additional file" //with -m flag
-- git push --force origin master
//Since the commit history has changed (the commit hash is different), you need to force push the changes:
-- Using `git commit --amend` and `git push --force` allows you to correct and refine your commit history, but it must be used responsibly to avoid disrupting the workflow of others.
-- git commit --amend --no-edit //The --no-edit option keeps the existing commit message.
</pre>
</p>
<hr>
<!-- --------------------------------------------------------------------------------------------- -->
<!-- git rebase -->
<!-- --------------------------------------------------------------------------------------------- -->
<h2>git rebase</h2>
<pre>
What is Git Rebase Interactive?
git rebase -i (interactive rebase) is a powerful Git command that allows you to rewrite and manipulate your commit history. It lets you modify individual commits, combine them, reorder them, or even remove them. This is particularly useful for cleaning up a series of commits before merging them into a main branch.
When to Use Interactive Rebase
Squashing Commits: Combine multiple commits into one.
Reordering Commits: Change the order of your commits.
Editing Commit Messages: Modify the messages of previous commits.
Removing Commits: Delete specific commits from the history.
Splitting Commits: Divide a single commit into multiple smaller commits.
-- My README.md file for git rebasea: https://github.com/Shahed-Chy-Suzan/git-test/tree/feature
- Squashing Commits (squash): Combine multiple commits into one.
- Reordering Commits: Change the order of your commits.
- Editing Commit Messages (reword): Modify the messages of previous commits. //edit an old commit message
- Removing Commits (drop): Delete specific commits from the history.
- Splitting Commits: Divide a single commit into multiple smaller commits.
-- reword //for edit specific commit message
-- git log --oneline
-- git rebase -i HEAD~2 //git rebase -i e57060e (j commit edit korbo tar agher commit hash)
-- press `i`
-- reword //for edit specific commit message //(in new window of editor)
-- press `esc`, `:wq` //or `esc`, `shift + zz`
-- press `i`
-- write new message for that commit (in new window of editor)
-- press `esc`, `:wq` //or `esc`, `shift + zz`
-- git push --force origin feature
-- edit //edit a specific commit/file
-- git log --oneline
-- git rebase -i 6fabd0d //j commit edit korbo tar agher commit hash
-- press `i`
-- `edit` instead of `pick` //for edit specific commit code/file //(in new window of editor)
-- press `esc`, `:wq` //or `esc`, `shift + zz`
-- then oi file e giye edit kore nibo code.
-- git add .
-- git status //checking edited/updated code tracked or not
-- git commit --amend // taile windown eshe commit messg ta edit korte bolbe.
-- git rebase --continue
-- git push --force origin feature
</pre>
<hr>
<p>rebase 1</p>
<p>edit with rebase</p>
<p>
git reorder <br>
- please explain the key command you used to actual move the commit <br>
- That depends on which editor you have configured. In my case it's vi, so it's "dd" to cut the line, and "p" to paste it.
</p>
<hr>
<!-- --------------------------------------------------------------------------------------------- -->
<!-- Random Resource -->
<!-- --------------------------------------------------------------------------------------------- -->
<h3>Random Resource</h3>
<ol class="randomResource">
<li>
<a href="https://www.sitepoint.com/git-interactive-rebase-guide/" target="_blank">https://www.sitepoint.com/git-interactive-rebase-guide/</a>
</li>
<li>
<a href="https://about.gitlab.com/blog/2020/11/23/keep-git-history-clean-with-interactive-rebase/#correcting-an-old-commit-message-with-git-rebase-interactive" target="_blank">https://about.gitlab.com/blog/2020/11/23/keep-git-history-clean-with-interactive-rebase/#correcting-an-old-commit-message-with-git-rebase-interactive</a>
</li>
<li>
<a href="https://hackernoon.com/beginners-guide-to-interactive-rebasing-346a3f9c3a6d" target="_blank">https://hackernoon.com/beginners-guide-to-interactive-rebasing-346a3f9c3a6d</a>
</li>
<li>
<a href="https://www.atlassian.com/git/tutorials/merging-vs-rebasing" target="_blank">https://www.atlassian.com/git/tutorials/merging-vs-rebasing</a>
</li>
<li>
<a href="https://www.freecodecamp.org/news/git-rebase-handbook/" target="_blank">https://www.freecodecamp.org/news/git-rebase-handbook/</a>
</li>
<li>
<a href="https://www.youtube.com/watch?v=3VFsitGUB3s" target="_blank">https://www.youtube.com/watch?v=3VFsitGUB3s</a>
</li>
<li>
<a href="https://www.youtube.com/watch?v=qsTthZi23VE" target="_blank">https://www.youtube.com/watch?v=qsTthZi23VE</a>
</li>
</ol>
<br><br>
</body>
</html>