git (GitHub CLI)
Packages:
sudo apt install gh git
Configuring gh and git
Login via (just follow the prompts)
gh auth login
Config username and email:
→ remove –global
option to just configure the login for one specific repository/directory
git config --global user.email "<email-address>"
git config --global 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 -m <message>
Push changes*:
git push origin <branch>
*Replace branch
with the concerning branch, e.g. main
.
git merge and git rebase
Merge:
git merge
Rebase:
git rebase
Differences:
Sourced from: stackoverflow.com - git merge & git rebase