git cheat-sheet
Git Cheat-Sheet
Repository creation:
From existing directory:
cd project_dir
git init
git add <dir><file1><file2>
or git add .
to stage all the files
From other repository :
git clone <git-hub repository url>
Commit and Status:
git commit -m "My message"
git status
For changes : git diff
Remote update:
Connect local to remote
git remote add origin <url>
Push to remote repository
git push -u origin main
Log:
All Commit: git log
File Commits: git log file
Branching:
List branches: git branch -a
New branch: git branch <branch-name>
Switch branch: git checkout branch
Push to new branch: git push origin <branch-name>
Merge:
git merge origin/<branch-name>