- Initialize empty git repo : git init
- Add file : git add filename.txt
- Commit : git commit -m "Some commit message"
- Check Status : git status
- List of tracked files : git ls-files
- Unstage : git reset HEAD filename.txt
- Revert to last commit : git checkout -- filename.txt
- Rename file using git : git mv filename.txt newfilename.txt
- Unstage a rename : git mn newfilename.txt filename.txt
- Delete a tracked file : git rm filename.txt
- Check commit history : git log
- Commit history in oneline and decorated with branching graph : git log --oneline --graph --decorated
- Commit history in a range : git log commit_hash_1...commit_hash_2
- Commit history some time ago : git log --since="1 hours ago" or git log --since="3 days ago"
- Commit history of a specific file : git log -- filename.txt
- Create alias : git config --global alias.alias_name "command after git goes here"
- Compare staged and unstaged changes : git diff
- Compare unstaged change with last commit : git diff HEAD
- Compare staged change with last commit : git diff --staged HEAD
- Limit diff to a specific file : git diff -- filename
- Compare between two commits : git diff commit_id_1 commit_id_2
- List all branches : git branch -a
- Create a new Branch : git branch my_new_branch_name
- Change branch : git checkout branch_name
- Change branch name : git branch -m oldName newName
- Delete Branch : git branch -d branchName
- Create and Change branch simultaneouly : git checkout -b branchName
- Merge a branch : git merge branch_name
bera5186 / learning-git Goto Github PK
View Code? Open in Web Editor NEWLearning Git in depth ๐๐