Fundamental Git Commands
Fındamental Git commands with their basic explanations list
Show files
status git statusCopy changes from a remote repo
git pullLocal retrieves(downloads) the latest meta-data info from the original repo(no file transfer)
git fetchAdd files
git add .Commit with message
git commit -m “explain commit”Command history
git logShow the previous command from the log(command history)
git log -n [number]Amend
git commit — amendAmend with message
git commit — amend -m “explain amend”Revert the action
git revert [commit hash ID]Applying a commit to another (used for undoing changes)
git-cherry-pickDelete commits(DANGEROUS)
git reset — hard [ID]Show the difference of actions
git diff [ID]..[ID][file_name]NEVER WORK ON THE DEFAULT BRANCH.
Get Cahit Barkin Ozer’s stories in your inbox
Join Medium for free to get updates from this writer.
Show branches
git branchCreate branch
git branch [branch_name]HEAD is a pointer that points to the “current branch”.
Change your branch
git checkout [branch_name]Create and change
git checkout -b[branch_name]Delete branch
git branch -D [branch_name]Create folder
touch [folder_Name]Store actions
git stashShow stash list
git stash listApplies changes and removes the one at the top
git stash popApplies changes and does not remove them from the list
git stash apply stash@{0}Combines the branch with the default branch
git merge[branch_name]Squash the previous commits into one
git merge -squash [branch_name]merge the history of two branches on a repository
git rebase [branch_name]Files with “.gitignore” extensions are for files that are not wanted to get tracked by the git. These files might be documents, multimedia, operating system files., application files, language and framework Files, files downloaded with package managers, Credentials, etc. .
Fork vs pull: With a Pull Request, changes made on the forked repository are merged with the original repository. With the push command, changes performed on the cloned repository can be transferred to the original repository.
Please don’t forget to applaud if you enjoyed my article. Thank you.
Resources:








