Git day-in and day-out
Everyday commands at a glance

Here is a list of Git commands that might be useful for daily work along with how they work:
- Let’s start with cloning a repository:
just to clone a project:
$ git clone https://clone-url-for-the-project.comClone a project into specific folder:
$ git clone https://clone-url-for-the-project.com "c:/path-to-your-folder/"
2. Branches:
create new branch
$ git checkout -b my-new-branch-namecheckout existing branch
$ git checkout existing-branch-name
3. Working with changes:
check the files changed
$ git statusstage all changes
$ git add .commit the changes
$ git commit -m "your-commit-message"push changes to origin
$ git push
4. Get latest:
get the changes for the branch you are in
$ git pullpull another branch into your local
$ git pull origin other-branch-name
5. Abort merge or Rebase:
If and When pull from different branch was a mistake. For more details on when to Merge or Abort, click here
if there are merge conflicts, you will have a branch name with MERGE or REBASE attached to your branch name:$ git pull origin other-branch-name
Resolve the conflicts
c:/Workspace/Project(my-existing-brnach|MERGE)
$ git abort --mergeor
c:/Workspace/Project(my-existing-brnach|REBASE)
$ git abort --rebase
6. Reset commits:
wish to reset all of your commits
$ git reset --hard HEADwish to remove just last 2 commits
$ git rest --hard HEAD~2if you want to know how many commits to undo
$ git logchoose number based on the log of commits
7. Reconcile your repository and branches:
IDE keeps information about all your previous branches. Even if the branches were deleted from origin. To update your information.
$ git pruneif you wish to check what information is missing
$ git prune --dry-run
Prune command is especially useful when you are trying to switch to a branch but your shell doesn’t know the branch exists. You can also do git pull on your existing branch to get the latest for the repository.
8. Stash your changes:
wish to keep your changes that are not ready to be committed
$ git stash save your-stash-nameto apply the stash back
$ git apply stash your-stash-name
9. Cherry-pick:
To pick and choose commit hashtags for the new branch:
do a git log on the branch to get the commit SHA
$ git log
output will be something like this:
commit 255dac3....... (HEAD -> branch, origin-branch)
Author: Indira.Raghavan <your-email>
Date: Tue Oct 13 18:10:26 2020 -0400choose the exact hash you need for your branch:
$ git cherry-pick <commit-SHA)
In conclusion:
Command line inputs are all in the now, everyone is using them. IDE’s are working on making it easier to provide UI tool that does all of these functions(often more intuitive) without command-line inputs. It is your preference to use the CLI instead of GUI. If you do wish to use the CLI, hope this article helps you with day-to-day commands.