Linux
Command
Library
Basics
Tips
Commands
GIT
Clone an existing repository
$
git
clone [url]
Initialize new version-controlled project
$
git
init
Save changes to the repository
$
git
add .
$
git
commit -m "first commit"
Current state of the repository
$
git
status
Create a new branch
$
git
branch [branchName]
List all remote or local branches
$
git
branch -a
Delete a branch
$
git
branch -d [branchName]
Merge changes into current branch
$
git
merge [branchName]
Checkout an existing branch
$
git
checkout [branchName]
$
git
switch [branchName]
Checkout and create a new branch with that name
$
git
checkout -b [newBranch]
$
git
switch -c [newBranch]
Create a tag
$
git
tag [tagName]
Delete the tag
$
git
tag -d [tagName]
Push tags
$
git
push --tags
Get the latest version of a repository
$
git
pull [branchName] [remoteURL/remoteName]
Add remote repository
$
git
remote add [remoteName] [remoteURL]
Define the author name to be used for all commits
$
git
config --global user.name [name]
Define the author email to be used for all commits
$
git
config --global user.email [email]
Helpful guides that come with Git
$
git
help -g
Undo the previous commit
$
git
revert HEAD^
Forget about files that were tracked but are now in .gitignore
$
git
rm -r --cached .
$
git
add .
$
git
commit -am "remove ignored files"
Send local commits to the remote repository
$
git
push [remoteURL/remoteName] [branch]
Store current work with untracked files
$
git
stash -u
Bring stashed work back to the working directory
$
git
stash pop
Remove a file from the working index (cached)
$
git
rm --cached [fileName]
Delete a file (force)
$
git
rm -f [fileName]
Remove an entire directory from the working index (cached)
$
git
rm -r --cached [directoryName]
Delete an entire directory (force)
$
git
rm -r -f [directoryName]
Delete a remote branch
$
git
push origin :[branchName]
Show commit log
$
git
log
$
git
log --oneline
Show changes
$
git
diff
Show remote URLs
$
git
remote -v
Amend last commit message
$
git
commit --amend
Blame a file
$
git
blame [fileName]
Cherry-pick a commit
$
git
cherry-pick [commitHash]
Rebase onto another branch
$
git
rebase [branchName]
> TERMINAL_GEAR
Curated for the Linux community
Copied to clipboard
> TERMINAL_GEAR
Curated for the Linux community