-
git init- Initialize a git repository -
git status- Gives the status of the git repository -
git add <filename>- Add a file to the index -
git add .- Add every file to the index -
git pull- Pull the files from the remote repository -
git push- Push changes from the local to the remote repository -
git branch- List all the branch in the repository -
git checkout -b newBranchName- Here-bflag creates a new branch and checkout to that branch, can also be written asgco -b newBranchName. -
git branch -d branchName- Deletes a branch -
git log- Lists all the logs of the repository- All the logs are in reversed order.
-
git log --oneline- Log in oneline -
git log --oneline --color --graph --decorate- Shows the git logs in a beautiful way with graph -
git stash- Reverts the branch to the remote branch. -
git restore --staged <file>- unstage the file -
git reset --hard <commit id>- reset the git directory to a git commit id, here--hardmake changes locally,--softdoesn't change the changes in your local directory.
-
Adding date in the commit
git commit -m "date" filenamegit commit -m "`date +'%Y-%m-%d'`" # 2020-01-25
-
Adding emoji's in the commit message - Use these emojis