Metainformationen zur Seite
GIT
Repo erstellen
git init
klonen
git clone /pfad/zum/repository git clone benutzername@host:/pfad/zum/repository
add and commit
git add <dateiname> git add * git add . git add -A #interactive git add -i #rm git rm <filename> git commit -m "Commit-Nachricht" #add and commit git commit -a -m "Commit-Nachricht"
remote
git push origin master git remote add origin <server> git remote add origin http..../test.git #push to branch git push origin <branch> #remove remote repo git remote remove origin
branch
#branch erstellen git checkout -b feature_x #del branch git branch -d feature_x #change back to master git checkout master #push to remote git push origin <branch> #merge git merge <branch> #switch branch git switch branch
pull/update
#get updates from repo (fetch and merge) git pull
diff/log/tag/show
#diff git diff <quell_branch> <ziel_branch> #tag git tag 1.0.0 1b2e1d63ff #log git log #status git status #show commit git show <id>
reset
#reset to last HEAD entrie git checkout -- <filename> #reset and set to remote state git fetch origin git reset --hard origin/master
config and tweaks
#GUI gitk #Color-UI git config color.ui true #log oneline git config format.pretty oneline git config --global user.name "myname" git config --global user.email myname@my-email.com #store pwd git config --global credential.helper store
to integrate
Command line instructions
You can also upload existing files from your computer using the instructions below.
Git global setup
git config --global user.name "Mr user" git config --global user.email "user@localhost.com"
Create a new repository
git clone git@gitlab.com:user/mygitr.git cd mygitr git switch -c main touch README.md git add README.md git commit -m "add README" git push -u origin main
Push an existing folder
cd existing_folder git init --initial-branch=main git remote add origin git@gitlab.com:user/mygitr.git git add . git commit -m "Initial commit" git push -u origin main
Push an existing Git repository
cd existing_repo git remote rename origin old-origin git remote add origin git@gitlab.com:user/mygitr.git git push -u origin --all git push -u origin --tags
https://www.heise.de/ratgeber/Einstieg-in-Git-und-GitHub-Erste-Projekte-realisieren-6216127.html?seite=all
https://www.heise.de/ratgeber/Einstieg-in-Git-und-GitHub-Erste-Projekte-realisieren-6216127.html?seite=all