- INIT, STATUS, ADD, COMMIT, LOG
Installation (linux)
sudo apt-get install gitConfig name for the repository (onetime setting)
git config --global user.name "Rapid1898"Config mail for the repository (onetime setting - use the mail using for github.com)
git config --global user.email "x@gmx.com"Create repository in the actual directory
git initAdd file to the repository / staging area (prepared for later commit)
git add file.xyzAdd all html-files to the repo / staging area
git add *.htmlAdd everything to the repository / staging area from the directory
git add .2nd way to add everything to the repository / staging area from the directory
git add *Add readme-file
git add README.mdremove specific file from the repository / staging area (before commiting!)
git rm --cached index.htmlActual status in the git-directoy (eg. added files, changed files, not added,...)
git statusCommit files which are added / changed in the repo (with comment) - taking a "snapshot"
git commit -m "comment"Show overview about the last activities
git logClone a repository in the actual path
git clone github-linkLink the acutal folder/repo to the github-repo
git remote add origin https://github.com/link/Test.gitPush with upstream definition (shorthand - to the master)
git push -u origin masterPush with upstream definition (longhand - to the branch "answer")
git push --set -upstream origin answerundo add command before (all files get set back to the initial state)
git resetundo the last commit
git reset HEAD~ignore changes eg. for xlsx on the local machine
git stash
Pull (update) files from GitHub
(-u saves the paths - so at the next push - it must be only typed push)
git pull -u origin master
Enable pushing with ssh-key in Idea and VSCode
Enable open ssh agent: https://dev.to/aka_anoop/how-to-enable-openssh-agent-to-access-your-github-repositories-on-windows-powershell-1ab8
Run commands: https://stackoverflow.com/questions/56490194/vs-code-bitbucket-ssh-permission-denied-publickey- create a file ".gitignore" in the root-folder of the respository
- this files / folders will be ignored when comitting (and so for pushing to the remote repository)
- github has for eg. some problems with files > 100MB
all files in this folder will be ignored
add folder: /prg/dist/*this specific file will be ignored
add file: /prg.xlsx- BRANCH, CHECKOUT, DIFF, MERGE)
Create a new branch with the name "newFeature"
git branch newFeatureChange to branch "newFeature" (from the master-branch)
git checkout newFeatureReturn to the master-branch
git checkout masterDelete branch
git branch -d newFeatureChange name of the branch - eg. for renaming branch "master" to "main"
git branch -m mainCreate a new branch named "new"
git checkout -b newShow the difference in the files
git diff headShow only the differences for the files which are not commited yet
git diff --stagedMerge the branch with the master
git merge newFeature
fork the initial repository on github (select personal account as target)
click fork-button in githubget the forked repository clone
click code-button to grab linkclone the repository to the local folder
git clone github-linkcreate branch "answer"
git branch answerset current branch to "answer"
git checkout answersee which branch is curently active (eg. main or answer)
git statusadd all files to the stage (all in the current folder)
git add .when something wrong were added (undo the whole add command)
(git reset)shows the actual files on the stage
git statuscommit files from stage ("take snapshot")
git commit -m "Completed"push with upstream definition (to the branch "answer")
git push --set-upstream origin answerchange from main to the branch "answer"
select branch on git hub with buttonmake an pull request to the original repository
click pull request button