Setup & Start
-
Setup
-
git --version
-> First , test in the Shell with , if
Git
are installed.
-
git-scm.com/downloads -> Git Download
-
git config --global user.name "your_username"
-
git config --global user.email "your@email.com"
-
git config --global --list
->Check the Settings
-
CREATE a Repository
-
Create a Repository in
GitHub, you can
choose Privat/Public and first NO Readme. Copy
the HTTPS Adress
-
git init
-
git add README.md
-
git commit -m "first commit"
-
git branch -M main
-
git remote add origin 'COPIED_HTTPS_ADRESS_HERE'
-
git push -u origin main
-
CLONE an existing Repository
-
Create a local folder
-
GitHub -> Repository -> copy the HTTPS/SSH Adress
-
git glone 'COPIED_HTTPS/SSH_ADRESS_HERE'
-
ls
-> to see the content
cd 'foldername'
-> to navigate into it
git pull
-> to update the newest remote (GitHub) version of main.
Delete Repository
-
comand + shif + .
DELETE A REPOSITORY
Change & Commit
-
SAVE a change
-
git add 'filename'
-> add one file
-
git add .
-> add all files
-
git commit -m 'commit'
->marks the change with a
meaningfull small message
-
git push
-> the changes are uploaded to the branch
-
Commits
-
git log --all
-> shows you all commits
-
git log --oneline
-> all commits in one line
-
git log --graph
-> shows you all commits graphically
-
q
-> you can get out of the view again.
-
Commit back and apply changes
-
git log --oneline
-> to display the list of commit IDs
and select and copy the id
-
git checkout -b "new-branch-name" "copied-commit-id"
-> to create a new branch from a specific commit and switch to this branch.
-
git add .
-
git commit -m "commit back"
-
git push origin "new-branch-name"
Branches
-
SHOW Branches
-
git branch
-> shows all existing branches. (\* ->
shows where you are at the moment)
-
git branch --all
-> all existing branches.
-
CREATE Branch
-
git branch 'featurename'
->creates a new branch
branch.
-
git switch -c 'featurename'
->creates a new
branch branch and switch to the branch
-
git checkout -b 'featurename'
->creates a new
branch branch and switch to the branch
-
CHANGE Branch
-
git checkout 'featurename'
-> switch to this
branch
-
git switch 'featurename'
->switch to this
branch
-
DELETE Branch
-
git branch -d 'featurename'
->Deletes the
branch 'featurename'
-
git branch -D 'featurename''
->
WITHOUT WARNING, the branch is deleted
regardless of its status
Mergin
-
When all renewals (branch merged) have been updated in main, they can be brought into our local BRANCH and updated as well.
-
git checkout 'yourlocalbranchname'
->If you are not in your branch
-
git merge main
-> main is merged with the branch. IMPORTANT: after that allways
-
git push
-
git pull origin main
->main is merged with the branch, you donĀ“t need a 'git push' after that.
-
git checkout main
->come back to main
-
git pull
->to update the newest remote (GitHub) version of main.
Review
git status
->list new or modified files not yet committed
git log --online
-> list commit hiytory with ID
git diff
->show changes to unstages files