Skip to main content
Useful 10 git commands

1.git checkout -b <branchname> :  create a branch from the parent branch and checkout the branch.
2.git checkout – : switch between 2 branches. (between last branch and the current branch)
3.git diff <filename> : dump the changes of the file in the console by comparing it with the       unmodifed file.
4.git add . && git commit -m “commit message” : add all the changes and commit with a message. Here basically we are executing 2 commands with ‘&&’.
5.git log –oneline : get all the commit messages in the current branch and display in one line with the hashcode.
git branch -a : view  all local and remote branches in the repositories.
6.git branch -D <branchname> : delete a local (un-merged) branch. Note you cannot delete a branch when it is your current branch.
7.git push origin :<branchname> : delete a remote branch.
git fetch origin <branchname> : fetch a specific remote branch without getting all the remote changes.
8.git reset –hard <commit-hash> : reset your local commit history to a specific commit-hash. Note after this reset , the changes will be permanently lost. If you do not want to lose permanently use –soft instead.

Comments

Popular posts from this blog

Reason and How to fix  Since angular 4  deep imports  are not supported. Before Angular 4 you could do this, for example .. import { EventEmitter} from ‘@angular/core/src/event_emitter’ but now in Angular 4 you can only go to  the first level ,