Git is a distributed version control system that tracks changes in your files, allowing you to revert to previous versions, collaborate with others, and maintain a history of your project.
.git
folder, which contains the version history.git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
git config --list
git init
git clone <repository-url>
git add <file-name>
git add .
git add *.txt
git commit -m "Commit message"
git commit -a -m "Commit message"
git status
git diff
git log
git log --oneline
git log --stat
git branch
git branch <branch-name>
git checkout <branch-name>
git checkout -b <branch-name>
git merge <branch-name>
git merge --no-ff <branch-name>
git rebase <branch-name>
git rebase -i <commit-hash>
git branch -d <branch-name>
git branch -D <branch-name>
git remote add origin <remote-url>
git remote -v
git fetch
git pull
git push origin <branch-name>
git push -u origin <branch-name>
git push origin --delete <branch-name>
git stash
git stash save "Stash message"
git stash list
git stash apply
git stash apply stash@{index}
git stash drop
git stash drop stash@{index}
git stash pop
git commit --amend -m "New commit message"
git reset --soft <commit-hash>
git reset --hard <commit-hash>
git revert <commit-hash>
git checkout -b feature-branch
# make changes
git add .
git commit -m "Add feature"
git checkout main
git merge feature-branch
git push origin main
git clone <forked-repo-url>
git remote add upstream <original-repo-url>
git fetch upstream
git checkout main
git merge upstream/main
git push origin main
git checkout feature-branch
git rebase main
git checkout main
git merge feature-branch
git push origin main