LinuxCommandLibrary

GIT

Save changes to the repository

$ git add .
copy
$ git commit -m "first commit"
copy

Create a new branch

$ git branch [branchName]
copy

Delete a branch

$ git branch -d [branchName]
copy

Merge changes into current branch

$ git merge [branchName]
copy

Checkout an existing branch

$ git checkout [branchName]
copy

Create a tag

$ git tag [tagName]
copy

Delete the tag

$ git tag -d [tagName]
copy

Push tags

$ git push --tags
copy

Get the latest version of a repository

$ git pull [branchName] [remoteURL/remoteName]
copy

Add remote repository

$ git remote add [remoteName] [remoteURL]
copy

Define the author name to be used for all commits

$ git config --global user.name [name]
copy

Define the author email to be used for all commits

$ git config --global user.email [email]
copy

Undo the previous commit

$ git revert HEAD^
copy

Forget about files that were tracked but are now in .gitignore

$ git rm -r --cached .
copy
$ git add .
copy
$ git commit -am "remove ignored files"
copy

Send local commits to the remote repository

$ git push [remoteURL/remoteName] [branch]
copy

Delete a file (force)

$ git rm -f [fileName]
copy

Delete an entire directory (force)

$ git rm -r -f [fileName]
copy

Delete a remote branch

$ git push origin :[branchName]
copy
Copied to clipboard