Skip to content

Instantly share code, notes, and snippets.

@samuelcolvin
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuelcolvin/9893426 to your computer and use it in GitHub Desktop.
Save samuelcolvin/9893426 to your computer and use it in GitHub Desktop.
Git commands

Standard commands

git clone git@github.com:[username]/[project-name].git
git pull
git fetch
git push
git status
git log
git diff file...
git commit -a -m "msg"
git commit --amend

Change URL

git remote set-url origin git@github.com:[username]/[project-name].git

Show URL

git remote show origin (shows more detail)

Change branch:

git checkout [branch-name]

Create and change to branch

git checkout -b [new-branch-name]

Merge another branch

git merge [branch-name]

List remotes

git remote [-v]

Remove Remote

git remote rm remote_name

Add submodule

git submodule add git@github.com:[username]/[project-name].git path/for/submod

Recursive clone

Remove Remote

git clone --recursive git@github.com:[username]/[project-name].git

Recursive push

git submodule foreach git push (only pushes submodules)
git push --recurse-submodules=on-demand

rebaseing explaination

Rebase 3 commits from head

git rebase -i HEAD~3

-i is interactive, Git base to a specific commit

git rebase -i <hash> (this should be the commit before the one you want to go back to)

Rebase to a different branch

git rebase upstream/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment