This is an old revision of the document!
git
Packages:
sudo apt install git
To login via GitHub install gh:
sudo apt install gh
Configuring gh and git
Login to GitHub via (just follow the prompts)
gh auth login
Config username and email:
→ add –global option to just configure the login for one specific repository/directory
git config user.email "<email-address>"
git config user.name "<github-username>"
Replace email-address with your GitHub email and github-username with your username.
Initialize directory for git
Change to the highest directory of your project, then intialize repository:
git init
Add the remote:
git remote add origin '<url>'
In case of GitHub <url> for example can be https://github.com/<username>/<repository>/.
Pushing changes to GitHub
Add files to commit:
git add /path/to/file(s)
View status of changes:
git status
Before starting to edit, sync external changes:
git fetch <remote-repo>
git pull origin <branch>
Create commit:
git commit -vs
Or use the more simplier command:
git commit -m <message>
Push changes:
git push origin <branch>
Replace branch with the concerning branch, e.g. main.
Reset to previous commit (deletes all changes, use stash before to save changes and only delete the commit itself):
git reset --hard <commit>
To then push changes/reset:
git push --force
git merge and git rebase
Merge:
git merge
Rebase:
git rebase
Differences:
Sourced from: stackoverflow.com - git merge & git rebase
