Skip to content

Commit f4b1106

Browse files
feat-krishnaacharyaa#378: created readme for git conflicts
1 parent c08f38c commit f4b1106

File tree

1 file changed

+41
-13
lines changed

1 file changed

+41
-13
lines changed

Diff for: GIT_CONFLICTS.md

+41-13
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,64 @@ Follow these steps in your main branch
1515

1616
<details>
1717
<summary>
18-
<em>Edit a commit</em>
18+
<em>Why the previous commits of another branch are showing in the new branch</em>
1919
</summary>
2020

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.
2522

26-
</details>
23+
![image showing the working of branches](https://github.com/rushil-b-patel/wanderlust/assets/96254453/1689fdd3-8ee5-4c29-9b69-f2eeed67f96e)
2724

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>
2829

2930
<details>
3031
<summary>
31-
<em>To Check the commit Tree:</em>
32+
<em>Edit a commit</em>
3233
</summary>
3334

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
62+
![git ammend showcase](https://github.com/rushil-b-patel/wanderlust/assets/96254453/4c5e73b1-e466-42b4-9053-d7044be4a50e)
63+
for more info, watch this [video](https://www.youtube.com/watch?v=q53umU5vMkk)
3664
</details>
3765

66+
3867
<details>
3968
<summary>
40-
<em>Undoing a commit from several commits ago</em>
69+
<em>To Check the commit Tree:</em>
4170
</summary>
4271

43-
- `git log`
44-
- `git revert [hash of the commit]`
72+
- Run `gitk` or `gitk --all` to visualize the commit tree.
73+
- `git log` show commit logs.
4574
</details>
4675

47-
4876
- **Rebase:**
4977
- `git fetch main`: Fetch the latest changes:
5078
- `git rebase upstream/main`: Rebase onto the upstream branch

0 commit comments

Comments
 (0)