Skip to content

Instantly share code, notes, and snippets.

@jneptune
Last active December 6, 2022 20:20
Show Gist options
  • Save jneptune/fb668589079e80c98415 to your computer and use it in GitHub Desktop.
Save jneptune/fb668589079e80c98415 to your computer and use it in GitHub Desktop.
GIT Commands and Actions

GIT Commands and Actions

Create Repo

New Local Repo git init [project-name]
Copy Remote Repo git clone [url] [?name]

Making Changes

Show Changes git status <-s>
Stage Changes git add [file] or git add .
Commit Staged Changes git commit -m [message]
Amend Previous Commit git commit --amend
Diff b/w Working and Staged git diff
Diff b/w Staged and HEAD git diff --staged or git diff --cached
Diff b/w Working and HEAD git diff HEAD
Unstage Changes to File git reset HEAD [file]
Discard Changes git checkout -- [file]

Remote

List Remotes git remote
Show Remote Detail git remote show [name]
Add Remote git remote add [name] [url]
Rename Remote git remote rename [original-name] [new-name]
Delete Remote git remote rm [name]
Push to Remote git push [remote] [branch]

Branches

List Branches git branch
Create Branch git branch [branch-name]
Switch to Branch git checkout [branch-name]
Merge Branch into current branch git merge [ branch ]
Merge Branch1 into Branch2 git merge [branch1] [branch2]
Delete Branch git branch -d [branch-name]
@karan-999
Copy link

karan-999 commented Aug 18, 2022

Thanks

@Aldhiaa
Copy link

Aldhiaa commented Nov 30, 2022

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment