Skip to main content

git

setup signing

git config --global gpg.format ssh
git config --global user.signingkey /PATH/TO/.SSH/KEY.PUB
git config --global commit.gpgsign true
git config --global gpg.ssh.allowedSignersFile ~/.ssh/allowed_signers # <- email key_type(ssh_ed25519) key

git verify-commit <commit>
git log --show-signature

solving merge conflicts

1. Switch to the main branch

First, ensure that you are on the main branch:

git checkout main

2. Merge the dev branch into main

Start the merge process from dev to main:

git merge dev

If there are any conflicts, Git will stop the merge and indicate which files are in conflict.

3. Identify conflicted files

Git will show you which files are in conflict. You can also check the status with:

git status

The conflicted files will be listed under "Unmerged paths".

4. Resolve conflicts in each file

Open the conflicted files in a text editor or IDE. Conflicts will be marked like this:

<<<<<<< HEAD
// changes in main
=======
// changes in dev
>>>>>>> dev
  • The content between <<<<<<< HEAD and ======= is from main.
  • The content between ======= and >>>>>>> dev is from dev.

You need to choose which changes to keep, or manually combine them. After resolving the conflicts, remove the conflict markers (<<<<<<<, =======, and >>>>>>>).

5. Stage the resolved files

After you've resolved all conflicts, stage the changes:

git add <file1> <file2> ...   # or use `git add .` to stage all resolved files

6. Complete the merge

After staging the resolved files, complete the merge with:

git commit

This will create a merge commit. If you don't want to open the editor for the commit message, you can add a commit message directly:

git commit -m "Resolved conflicts and merged dev into main"

7. Push the changes to the remote repository

Finally, push your changes to the remote main branch:

git push origin main

Summary of Commands:

  1. git checkout main
  2. git pull origin main
  3. git merge dev
  4. Resolve conflicts manually in the files
  5. git add <file1> <file2> ...
  6. git commit
  7. git push origin main

These steps will help you resolve merge conflicts using only Git commands.