2026-03-13 (3VO): Git (SSH), C++ Intro#
Basic git Workflow: add, commit, push (, pull)#
View changes
Current working directory somewhere inside the tree,
$ git status ...
git addchanges: stage for next commit$ git add file.h file.cpp ...
Review repo situation
$ git status ...
git commitwhat you stagedEither non-interactive (giving the commit message as a commandline parameter)
$ git commit -m 'frobozz the foobar'
Or letting git pop up your favorite
$EDITOR$ git commit
git pushgit pull
SSH, And Using It For Git Repository Access#
From SSH: Secure Shell:
Exercise: Key Pair, Deployed To Codeberg#
Create key pair. Leave passphrase empty (else you’ll have to type it in over and over, just like the HTTPS password)
Send to trainer
Public key (
id_rsa.pub)Codeberg account name
Deploy SSH public key on Codeberg (account (icon above right) -> “Settings” -> “SSH / GPG keys”)
You have a clone of your fork of the upstream repo; change that clone’s upstream URL from HTTPS to SSH.
First, look:
$ git remote origin $ git remote -v origin https://codeberg.org/_codebergaccountname_/FH-STECE2024.git (fetch) origin https://codeberg.org/_codebergaccountname_/FH-STECE2024.git (push)
Then set:
$ git remote set-url origin ssh://git@codeberg.org/_codebergaccountname_/FH-STECE2024.git
Distributed git: Update Your Fork From Upstream#
Current situation#
Wanted: merge changes from upstream#
Create a remote for upstream https://codeberg.org/jfasch/FH-STECE2024.git
$ git remote add upstream https://codeberg.org/jfasch/FH-STECE2024.git
$ git remote -v origin https://codeberg.org/_codebergaccountname_/FH-STECE2024.git (fetch) origin https://codeberg.org/_codebergaccountname_/FH-STECE2024.git (push) upstream https://codeberg.org/jfasch/FH-STECE2024.git (fetch) upstream https://codeberg.org/jfasch/FH-STECE2024.git (push)
Fetch from upstream
$ git fetch upstream ... roedel ...
Merge
upstream/masterinto your localmasterbranchCheck that your current branch is
master,$ git branch * master
Merge,
$ git merge upstream/master
Note that this is not always so easy - you might have to resolve conflicts.
Push to default location - your fork,
$ git push
Shorthand:
git pull. This is the same asfetchfollowed bymerge