GIT – Overview
October 24th, 2019 10:35 PM | by Alfred Markus Paar | Posted in Software
GIT basic commands list:
- git status
- shows all modifications in the workspace, differences of the local repository, etc.
- git add <data> or . (for all)
- stages workspace data
- git commit
- commits data to the local repository
- command + comment: git commit -m”<comment>”
- git checkout <data>
- unstages data to workspace
- git checkout HEAD
- reverts workspace changes from local repository
- git diff
- shows differences between workspace and index
- git diff HEAD
- shows differences of workspace and local repository
- git log
- shows the commit logs
GIT advanced commands list:
- branches
- git branch -a
- list all branches
- -v option for more detailed infos
- git branch <branchname>
- create a new branch
- git checkout <branchname>
- switches branch
- git merge <branchname>
- merges slected branch to actual branch
- git branch -d <branchname>
- deletes branch
- git branch -a
- stashing
- git stash
- save workspace changes to stash AND go back to the latest commit
- git stash save ‘<comment>’
- save workspace changes to stash with specific comment AND go back to the latest commit
- git stash list
- list complete stash: stash@{#} where # is stash number
- git stash apply
- restore the last saved stash to the workspace
- git stash apply stash@{#}
- restore the selected stash number to the workspace
- git stash drop
- drops the last saved stash
- git stash clear
- clear all stashes
- Example of using stashing when working on the wrong branch:
- git stash
- git checkout <correct branch>
- git stash apply
- git stash
Leave a Reply