Fundamental Git Commands
Fındamental Git commands with their basic explanations list
Show files
status git status
Copy changes from a remote repo
git pull
Local retrieves(downloads) the latest meta-data info from the original repo(no file transfer)
git fetch
Add files
git add .
Commit with message
git commit -m “explain commit”
Command history
git log
Show the previous command from the log(command history)
git log -n [number]
Amend
git commit — amend
Amend 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-pick
Delete commits(DANGEROUS)
git reset — hard [ID]
Show the difference of actions
git diff [ID]..[ID][file_name]
NEVER WORK ON THE DEFAULT BRANCH.
Show branches
git branch
Create 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 stash
Show stash list
git stash list
Applies changes and removes the one at the top
git stash pop
Applies 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: