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.
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
Post a Comment