work

Docker and Apptainer Using Git Asciinema Jekyll

c++

Assertions Debugging Profiling

general

Vacation Checklist


Branches

Create new branch and switch to it:

git checkout -b branchname

Switch to an existing branch:

git checkout branchname

Merge changes from branch1 into branch2 (one of them can be main). Use rebase for a clean history. Alternatively, you can use merge to keep the history of both branches.

git checkout branch2
git merge/rebase branch1 

If conflicts arises:

  1. Open each conflicted file (<<<<<<<, =======, >>>>>>> markers).
  2. Manually resolve the conflicts by editing the file.
  3. After resolving conflicts, mark the files as resolved:
    git add conflicted_file
    

If necessary, keep one version of the other of one file:

git checkout --ours conflicted_file  # Keep our version (the rebase source)
git checkout --theirs conflicted_file  # Keep their version (the rebase target)

After choosing one version, you still need to git add the file to mark it as resolved.

git add conflicted_file

Finalizing rebase (notice commit w/o message):

git rebase --continue
git push origin branch2

The status can be:

Push a branch to remote:

git push -u origin branchname

Delete a remote branch:

git push origin --delete branchname

List all remote branches: