You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: GIT_CONFLICTS.md
+41-13
Original file line number
Diff line number
Diff line change
@@ -15,36 +15,64 @@ Follow these steps in your main branch
15
15
16
16
<details>
17
17
<summary>
18
-
<em>Edit a commit</em>
18
+
<em>Why the previous commits of another branch are showing in the new branch</em>
19
19
</summary>
20
20
21
-
-`git reset --soft HEAD~1` gets back to the last commit(for more information refer this [blog](https://www.datacamp.com/tutorial/git-reset-revert-tutorial) )
22
-
- or
23
-
-`git commit --amend`: ammend the most recent commit.
24
-
-`git commit --amend -m "New commit message"` : you can set the commit message directly
21
+
When you create a new branch from a particular branch, you'll start from the point where that branch currently is. So all commit history will be there in the new branch as well.
25
22
26
-
</details>
23
+

27
24
25
+
A good rule of thumb is to always create a new branch from the branch that you intend to eventually merge the new branch into (main branch). So if D is intended to be merged into main at some future point in time, create it from the current tip of main.
26
+
27
+
for more details refer this [blog](https://www.reddit.com/r/git/comments/l7epj0/why_does_my_new_branch_contain_commits_from/)
28
+
</details>
28
29
29
30
<details>
30
31
<summary>
31
-
<em>To Check the commit Tree:</em>
32
+
<em>Edit a commit</em>
32
33
</summary>
33
34
34
-
- Run `gitk` or `gitk --all` to visualize the commit tree.
35
-
-`git log` show commit logs.
35
+
1.`git add `: Add new changes
36
+
2.`git commit --amend --no-edit`: it will combine the new staged files to the last commit.
37
+
38
+
**or**
39
+
40
+
When calling git reset, you need to specify the commit to reset to or you can specify an ancestor of HEAD, the current commit, using the tilde (~) suffix.
41
+
-`git add .`
42
+
-`git commit -m "This commit is a mistake"`
43
+
-`git reset HEAD~`
44
+
-`git add main.py # need to re-add files after reset`
45
+
-`git commit -m "This commit corrects the mistake"`
46
+
47
+
To undo the last two commits, use the commands:
48
+
-`git add .`
49
+
-`git commit -m "This commit is a mistake"`
50
+
-`// make changes`
51
+
-`git add .`
52
+
-`git commit -m "This commit is another mistake"`
53
+
-`git reset HEAD~2`
54
+
-`git add .`
55
+
-`git commit -m "this commit corrects both mistakes"`
56
+
57
+
for more info refer this [blog](https://sentry.io/answers/undo-the-most-recent-local-git-commits/)
58
+
59
+
**or**
60
+
61
+
-`git commit --amend -m "New commit message"`: it will chnage the last commit message
0 commit comments