1
1
mirror of https://github.com/namibia/awesome-cheatsheets.git synced 2024-11-24 21:57:38 +00:00

Merge pull request #141 from thangtd-0050/patch-1

Add some useful git commands
This commit is contained in:
Julien Le Coupanec 2020-10-02 19:29:29 +02:00 committed by GitHub
commit ad8febdfe2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,7 +4,9 @@ git clone <address> # creates a git repo from given address (get the address fro
git add file.txt # adds(stages) file.txt to the git
git add * # adds(stages) all new modifications, deletions, creations to the git
git reset file.txt # Removes file.txt from the stage
git reset --hard # Throws away all your uncommitted changes, hard reset files to HEAD
git rm file.txt # removes file.txt both from git and file system
git rm --cached file.txt # only removes file.txt both from git index
git status # shows the modifications and stuff that are not staged yet
git branch # shows all the branches (current branch is shown with a star)
@ -19,11 +21,19 @@ git cherry-pick <commit_id> # merge the specified commit
git remote # shows the remotes
git remote -v # shows the remote for pull and push
git remote add my-remote <address> # creates a remote (get the address from your git-server)
git remote rm my-remote # Remove a remote
git log # shows the log of commits
git log --oneline # shows the log of commits, each commit in a single line
git commit -m "msg" # commit changes with a msg
git commit --amend # combine staged changes with the previous commit, or edit the previous commit message without changing its snapshot
git commit --amend --no-edit # amends a commit without changing its commit message
git push my-remote my-branch # pushes the commits to the my-remote in my-branch (does not push the tags)
git show # shows one or more objects (blobs, trees, tags and commits).
git diff # show changes between commits, commit and working tree
git diff --color # show colored diff
git tag # shows all the tags
git tag -a v1.0 -m "msg" # creates an annotated tag
git show v1.0 # shows the description of version-1.0 tag