Note: Click on π to see an example.
git config --global user.name "<Enter name here>"to set username. πgit config --global user.email <email>to set an email. πgit config -hto see the help documentation for βgit configβ command. πgit help <command>to get the help documentation for a specific git command. πcd <file/folder path>to change directory. πgit initto initialize a git repository in the current working directory. πgit statusto check the current state of the repository. πgit add <filename>to track a file in the working directory πgit rm --cached <filename>to untrack a file in the working directory π
Tip: To ignore a file/folder create a txt file and rename it as .gitignore , then add the files that are to be ignored such as .txt files etc. π
git add .to track all the files present in the directory πgit commit -mto Commit all the staged changes (To commit means to take a snapshot of the repository at particular point of a time). πgit commit -m "<Your Message>"to add a message for a commit directly in the command line πgit restore --staged <filename>to remove the changes that were previously staged πgit commit -a -m "<message>"to stage all modified and delete files automatically and create a new commit with the specified commit message in a single step. πgit rm "<filename>"to delete a file. πgit restore "<filename>"to restore a file. πgit mv "<oldname>" "<newname">to rename a file. πgit log /git log --onelineto view the commit history of the repository, i.e see all the commit in chronological order. π πgit commit -m "<newMessage>" --amendto change the message of recent commit (Using amend command changes the commit ID and hence should not be used in public repositories). πgit log -p (-2)to see the commit history along with the actual content changes (patch) introduced in each commit. πgit show <commit_ID>to view detailed information about the specified commit, including the commit message and changes introduced. πgit rm <filename>to remove a file from both, working directory and git repository.git checkout <filename>to Undo unstaged changes. πgit checkout <filename> -pto interactively preview and selectively discard changes within the specified file before restoring it to the state of the last commit.git reset HEAD <filename>to remove files from staging. πgit revert HEADto revert/ rollback to a previous commit. πgit branchto see, create and manages all the branches in a repository. πgit branch <new-branch-name>to create a new branch. πgit checkout <branch-name>to switch to a new created branch. πgit checkout -b <branch-name>to create and switch to a new branch. πgit branch -s <branch-name>to delete a branch. πgit merge <branch-name>to merge a branch. πgit merge --abortto abort in case of merge conflicts.git log --graph --onelineto get detailed view about how a merge happened.