Last active
December 17, 2015 19:29
-
-
Save datt/5661005 to your computer and use it in GitHub Desktop.
Useful git commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ######## 1.Create a branch without parent | |
| # useful when scenario is: Suppose if you are on develop branch and you want to create a branch say feature having no code of develop branch. How can you do that? | |
| git checkout --orphan feature | |
| # this creates branch without parent, you can now pull remote feature into this branch. | |
| ######## 2. Add changes to previous commit or editing a git commit | |
| # first add files you want to add in commit | |
| git add . OR git add modified files | |
| git commit --amend | |
| # This will open editor, just save changes. You can check 'git log'. | |
| ####### 3. Remove all modifications and untracked files from current directory. | |
| git reset --hard HEAD | |
| # This will revoke changes of modified files. | |
| git clean -fd | |
| # This will remove all un-tracked files from directory. | |
| # Use -x option only if you want to remove un-tracked files which are in .gitignore. | |
| ####### 4. Changing git remote origin | |
| git remote set-url origin <new git url> | |
| #e.g. git remote set-url origin [email protected]:webonise/rails-mlb-eyesite.git | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment