Git General
Links
Global setup
git config --global user.name "username"
git config --global user.email "your@email.com"
Check setup
git config --list
Save Credentials
git config credential.helper store
Not verify https Certificates
git config --global http.sslVerify false
Set commandline colors
git config color.status.added "green bold"
git config color.status.changed "yellow bold"
git config color.status.untracked "red bold"
Set commandline editor
git config --global core.editor "nano -w"
Git Repo Creation / Cloning
Create new repo
git init
Status of repo
git status
Settings of repo
git remote -v
Clone existing repo
git clone git@gitlab.hevs.ch:course/ElN/eln_labs.git
cd eln_labs
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
Revert to last commit state
go back to last committed servers state (can't be undone)
git reset --hard
Existing folder
cd existing_folder
git init
git remote add origin git@gitlab.hevs.ch:course/ElN/eln_labs.git
git add .
git commit -m "Initial commit"
git push -u origin master
Switch to new Remote
cd existing_repo
git remote rename origin old-origin
git remote add origin git@gitlab.hevs.ch:course/ElN/eln_labs.git
git push -u origin --all
git push -u origin --tags
Get Remote Information
git remote show origin
Change Push Remote URL
git remote set-url --push <new_repo_push_url>
Git Repo information
# Status about current files ion folder
git status
# Status about last commits
git log --oneline
Add Files
# Stage a File
git add README.md
# Commit file
git commit –m "Initial commit, add README file"
Checkout
# Checkout certain commit
git checkout e006db0 -b inspectingPrev
# Checkout given branch
git chekout master
Push
git push origin master
Branch
# Create new branch
git branch dev_branch_1
# List all existing branches
git branch
# Checkout certain branch
git branch dev_branch_1
# Delete certain branch
git branch -d dev_branch_1
Merge
# Checkout branch you want to merge into
git checkout master
# Merge the two branches
git merge dev_branch_1