git and github - tlam/Wiki GitHub Wiki
git
-
Remove file from index
git rm --cached indexed_file
-
Cloning from remote ssh with a specific port 1234
git clone ssh://[email protected]:1234/home/username/project
-
Checking out from master
git fetch; git checkout -f origin/master
-
Restore an uncommitted deleted file,
deleted_file.py
:git reset -- deleted_file.py git checkout -- deleted_file.py
-
Stash local change while updating tree:
git stash --patch
Press
a
to stash the change you want andd
to skip over the change you don't want stashed.git pull
andgit stash pop
can be followed to get the latest tree and merge the old change back. -
Disable paged output for
git branch
git config --global pager.branch false
Branching
-
Create a new branch called
maple
git branch maple
-
See all branches
git branch maple * master
-
Switch to the maple branch
git checkout maple
-
After committing a change to the branch, push the branch to github
git push origin maple
-
Delete local branch
git branch -d maple
-
Delete a branch remotely
git push origin --delete maple
-
Git revert
Git Revert
- Create a git branch, git branch revert-new-attribute
- git checkout revert-new-attribute
- git revert -m 1 abc123
- git push --set-upstream origin revert-new-attribute