Linux
Command
Library
Commands
Basics
Tips
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]
Checkout and create a new branch with that name
$
git
checkout -b [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 origin [url]
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 [fileName]
Delete a remote branch
$
git
push origin :[branchName]
Copied to clipboard