Skip to main content

Command Palette

Search for a command to run...

Linux & Git-GitHub Cheat Sheet

Published
β€’4 min read
Linux & Git-GitHub Cheat Sheet

🐧 Linux Commands Cheat Sheet

CommandDescription
πŸ“‚ File and Directory Operations
lsList files and directories in the current directory.
ls -lList files and directories with detailed information.
ls -aList all files, including hidden ones.
cdChange the current directory.
cd ..Move up one directory level.
cd ~Navigate to the home directory.
mkdirCreate a new directory.
rmdirRemove an empty directory.
cpCopy files or directories.
cp -rCopy a directory and its contents.
mvMove or rename files and directories.
rmRemove files.
rm -rRemove a directory and its contents.
πŸ“„ Viewing and Editing Files
catDisplay the contents of a file.
headDisplay the first 10 lines of a file.
tailDisplay the last 10 lines of a file.
nanoOpen a file in the Nano text editor.
grepSearch for a specific pattern in a file.
πŸ” System Information
pwdPrint the current working directory.
dfDisplay disk usage information.
freeShow memory usage statistics.
psDisplay currently running processes.
πŸ”’ File Permissions
chmodChange the access permissions of a file or directory.
chownChange the ownership of a file or directory.
πŸ”§ Networking Commands
pingTest network connectivity to a host.
ifconfig / ipShow network interface configuration.
wgetDownload files from the web.
πŸ“¦ Package Management (Debian-based)
apt updateUpdate the list of available packages.
apt upgradeUpgrade all installed packages to their latest versions.
apt installInstall a new package.
apt removeRemove an installed package.

🌐 Git & GitHub Cheat Sheet

CommandDescription
πŸ“ Git Basics
git initInitialize a new Git repository.
git clone <repository-url>Clone an existing repository from a remote source.
git statusShow the current status of the working directory and staging area.
git add <file>Stage a file for the next commit.
git add .Stage all changes in the current directory.
git commit -m "<message>"Commit staged changes with a message.
git logView the commit history.
git diffShow changes between commits, the working tree, and the index.
πŸ”„ Branching
git branchList all branches in the repository.
git branch <branch-name>Create a new branch.
git checkout <branch-name>Switch to a specified branch.
git checkout -b <branch-name>Create and switch to a new branch.
git merge <branch-name>Merge the specified branch into the current branch.
git branch -d <branch-name>Delete a specified branch.
🌐 Remote Repositories
git remote -vList all configured remote repositories.
git remote add <name> <url>Add a new remote repository.
git fetch <remote>Fetch changes from a remote repository without merging.
git pull <remote> <branch>Fetch and merge changes from a remote branch.
git push <remote> <branch>Push local changes to a remote repository.
πŸ”§ Stashing Changes
git stashStash the current changes in a temporary storage.
git stash listList all stashed changes.
git stash applyApply the most recent stash.
git stash popApply the most recent stash and remove it from the stash list.
πŸ” Viewing Changes
git show <commit>Show changes made in a specific commit.
git blame <file>Show what revision and author last modified each line of a file.
πŸ”— Tagging
git tagList all tags in the repository.
git tag <tag-name>Create a new tag for the current commit.
git push origin <tag-name>Push a specific tag to the remote repository.
πŸ›  Configuration
git config --global user.name "<name>"Set the global username for Git commits.
git config --global user.email "<email>"Set the global email for Git commits.
git config --global core.editor <editor>Set the default text editor for Git.

πŸš€ Conclusion

This cheat sheet provides a comprehensive overview of essential Linux commands Git and GitHub commands. By familiarizing yourself with these commands, you'll enhance your workflow and efficiency in version control and your efficiency and productivity in using the Linux commandsπŸ––