GIT Cheatsheet

Linux Basic Commands :


  • ls : Lists all files and directories in the present working directory.
  • ls -la : To check hidden files.
  • cd : It is used to change current working directory.
  • cd .. : To move one directory up.
  • cd- : To move your previous directory.
  • pwd : To find out the path of current working directory.
  • sudo : Allows regular users to run programs with the security privileges of the superuser or root.
  • touch : To create empty/blank new file.
  • mkdir : To make a new directory. (Folder)
  • cat : It is used to list the content of a file on standard output.
  • cat > filename : Create a new file.
  • cat >> filename : Add/Append data in file.
  • cat f1 f2 > f3 : Joins two files (f1 & f2) and store the output of them in a new file f3.
  • rm : Used to delete a file.
  • rm -rf : Remove directories and their contents recursively.
  • rmdir : To delete a directory.
  • head : Return the specified number of lines from the top.
  • tail : Return the specified number of lines from the bottom.
  • echo : To print any text.
  • cp : Used to copy files from the current directory to a different directory.
  • df : Report file system disk space usage.
  • w : Show who is logged on and what they are doing.
  • mount : Used to mount a file system.
  • chown : For changing the ownership of a file/directory.
  • chmod : Command to change file permissions.
  • grep : It is use to search for pattern in each file or standard input.
  • useradd or adduser : Add new user or change existing users’ data.
  • userdel : To remove a newly created user.
  • groupadd : Add new group.



Git-GitHub Basic Commands :


  • git init : Create empty Git repo in the specified directory.
  • git clone : Clone repo located at onto local machine. The original repo can be located on the local filesystem or on a remote machine via HTTP or SSH.
  • git config user.name : Define the author name to be used for all commits in the current repo. Devs commonly use — global flag to set config options for the current user.
  • git add : Stage all changes in for the next commit. Replace with a to change a specific file.
  • git commit -m "<message>" : Commit the staged snapshot, but instead of launching a text editor, use it as the commit message.
  • git status : List which files are staged, unstaged, and untracked.
  • git log : Display the entire commit history using the default format. For customization see additional options.
  • git diff : Show unstaged changes between your index and working directory.
  • git reset <commit> : Move the current branch tip backward to, and reset the staging area to match, but leave the working directory alone.
  • git branch : List all of the branches in your repo.
  • git checkout -b <branch> : Drop the -b flag to check out an existing branch. Add a <branch>argument to create a new branch with the name.
  • git merge <branch> : Merge <branch>into the current branch.
  • git revert <commit> : Create a new commit that undoes all of the changes made, then apply it to the current branch.
  • git reset <file> : Remove from the staging area, but leave the working directory unchanged. This unstages a file without overwriting any changes.
  • git rebase : Rebase the current branch onto. can be a commit ID, branch name, tag, or a relative reference to HEAD.
  • git reflog : Show a log of changes to the local repository’s HEAD. Add — relative-date flag to show date info or - all to show all refs.
  • git remote add : Create a new connection to a remote repo. After adding a remote, you can use it as a shortcut for in other commands.
  • git fetch : Fetches a specific, from the repo. Leave off to fetch all remote refs.
  • git pull <remote> : Fetch the specified remote’s copy of the current branch and immediately merge it into the local copy.
  • git push <remote> <branch> : Push the branch to, along with necessary commits and objects. Creates named branch in the remote repo if it doesn’t exist.
  • git config --global user.name <name> : Define the author name to be used for all commits by the current user.
  • git config --global user.email <email> : Define the author email to be used for all commits by the current user.
  • git config --global --edit : Open the global configuration file in a text editor for manual editing.
  • git stash : Save modified and staged changes.
  • git stash list : List stack-order of stashed file changes.
  • git stash pop : Write working from the top of the stash stack.
  • git stash drop : Discard the changes from the top of the stash stack.



Thank you for reading! I hope you find this article helpful.

Happy Learning :)


To view or add a comment, sign in

Others also viewed

Explore topics