Skip to content

Commit c08f38c

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

File tree

1 file changed

+23
-64
lines changed

1 file changed

+23
-64
lines changed

Diff for: GIT_CONFLICTS.md

+23-64
Original file line numberDiff line numberDiff line change
@@ -2,97 +2,56 @@
22

33
<details>
44
<summary>
5-
<em>How can I know if I’m in a bad situation?</em>
5+
<em>How to Hard Sync local Master with Original Upstream</em>
66
</summary>
77

8-
- Run `gitk` or `gitk --all` to visualize the commit tree.
9-
- Check if `git log` shows any merge commits, indicating a lack of proper synchronization with the upstream branch.
10-
</details>
11-
12-
<details>
13-
<summary>
14-
<em>How to Hard Sync Master with Upstream</em>
15-
</summary>
16-
17-
To hard sync your local master branch with the upstream master branch, follow these steps in your main branch:
18-
19-
- `git remote add upstream /url-to-original-repo`
20-
- `git fetch upstream`
8+
Follow these steps in your main branch
9+
(upstream" is the original repository and "origin" is the fork one) :
10+
- `git checkout main`
11+
- `git pull upstream main`
2112
- `git reset --hard upstream/main`
2213
- `git push origin main --force`
2314
</details>
2415

25-
## Better commits
26-
27-
- Avoid committing unnecessary files:
28-
- Avoid using `git commit -a`, which commits everything.
29-
- Use targeted commit commands:
30-
- Use `git add` to stage specific files.
31-
- Use `git add -p` for a patch mode to review changes before staging.
32-
- Ensure changes are correct before committing:
33-
- Use `git diff --cached` to display staged changes.
34-
- Use `git commit -v` to view diffs while writing the commit message.
35-
36-
If you want to make sure about what you’re committing, use `git diff --cached` to display the ready-to-commit changes. Also, I like to use `git commit -v`, which displays the diff as a comment, so that I can view it while writing the commit message.
37-
3816
<details>
3917
<summary>
4018
<em>Edit a commit</em>
4119
</summary>
4220

43-
- `git reset --soft HEAD^`: Reset to the previous commit without changing files.
44-
- Edit the necessary changes.
45-
- `git commit -a -v -c ORIG_HEAD`: Recommit with the same message and verify changes.
46-
- After pushing, use force push: `git push -f`.
47-
</details>
48-
49-
<details>
50-
<summary>
51-
<em>What should I do if I’m in a bad situation?</em>
52-
</summary>
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
5325

54-
- **Rebase:**
55-
- Fetch the latest changes: `git fetch main`
56-
- Rebase onto the upstream branch: `git rebase upstream/main`
57-
- **Remove merge commits:**
58-
- Fetch latest changes: `git fetch upstream`
59-
- Discard all changes and reset: `git reset --hard upstream/main`
60-
- **Keep your changes:**
61-
- Create a backup branch: `git branch branchname`
62-
- Safely reset your branch
63-
- Pull changes back to master: `git cherry-pick branchname 1234567890abcdef1234567890abcdef12345678`
6426
</details>
6527

28+
6629
<details>
6730
<summary>
68-
<em>Recovering from a bad merge or accidental deletion</em>
31+
<em>To Check the commit Tree:</em>
6932
</summary>
7033

71-
- `git reflog`
72-
- `git reset HEAD@{index}`
34+
- Run `gitk` or `gitk --all` to visualize the commit tree.
35+
- `git log` show commit logs.
7336
</details>
7437

7538
<details>
7639
<summary>
77-
<em>Amending the last commit</em>
40+
<em>Undoing a commit from several commits ago</em>
7841
</summary>
7942

80-
- `git commit --amend --no-edit`
43+
- `git log`
44+
- `git revert [hash of the commit]`
8145
</details>
8246

83-
<details>
84-
<summary>
85-
<em>Changing the last commit message</em>
86-
</summary>
8747

88-
- `git commit --amend`
48+
- **Rebase:**
49+
- `git fetch main`: Fetch the latest changes:
50+
- `git rebase upstream/main`: Rebase onto the upstream branch
8951
</details>
9052

91-
<details>
92-
<summary>
93-
<em>Undoing a commit from several commits ago</em>
94-
</summary>
9553

96-
- `git log`
97-
- `git revert [saved hash]`
98-
</details>
54+
- Avoid committing unnecessary files:
55+
- Avoid using `git commit -a`, which commits everything.
56+
- Use targeted commit commands:
57+
- Use `git add` to stage specific files.

0 commit comments

Comments
 (0)