When it comes to commands, there come numerous commands in a software developer head or one that is mastering over git but even only a few of them are used frequently in the enterprising domains that are used frequently by developers in order to boost workflow. So here we will be listing a couple of them prior to dividing them into categories in order to perceive real quick. These commands are peculiar curated allowing to go from scratch from creating a new repository and playing further creating branches, merging to master branch.
Categories are as follows:
- To create
- To make local changes
- To commit history
- Branches and tags
- To update and publish
- To merge and reuse
- To undo
Let us do define commands that do fall under these categories that are listed below as follows:
Type 1: CREATE
- Clone an existing repository: git clone
- Create a new local repository: git init
Type 2: LOCAL CHANGES
- Changed files in your working directory: git status
- Changes to tracked files: git diff
- Add all current changes to the next commit: git add
- Add some changes to the next commit: git add -p
- Commit all local changes In tracked files: git commit -a
- Commit previously staged changes: git commit
- Change the last commit: git commit –amend
Type 3: COMMIT HISTORY
- Show all commits. starting with newest: git log
- Show changes over time for a specific file: git log -p
- Who changed what and when in: git blame
Type 4: BRANCHES & TAGS
- List all existing branches: git branch -av
- Switch HEAD branch: git checkout
- Create a new branch based on your current HEAD: git branch
- Create a new tracking branch based on a remote branch: git checkout – -track
- Delete a local branch: git branch -d
- Mark the current commit with a tag: git tag
Type 5: UPDATE and PUBLISH
- List all currently configured remotes: git remote -v
- Show Information about a remote: git remote show
- Add new remote repository, named remote: git remote add
- Download all changes from but don’t integrate into HEAD: git fetch
- Download changes and directly merge/integrate into HEAD: git pull
- Publish local changes on a remote: git push
- Delete a branch on the remote: git branch -dr
- Publish your tags: git push –tags
Type 6: MERGE & REUSE
- Merge into your current HEAD: git merge
- Rebase your current HEAD onto git rebase
- Abort a rebase: git rebase – -abort
- Continue a rebase after resolving conflicts: git rebase – -continue
- Use your configured merge tool to solve conflicts: git mergetool
- Use your editor to manually solve conflicts and (after resolving) mark tile as resolved: git add, git rm
Type 7: UNDO
- Discard all local changes in your working directory: git reset -hard HEAD
- Discard local changes in a specific file: git checkout HEAD
- Revert a commit (by producing a new commit with contrary changes): git revert
- Reset your HEAD pointer to a previous commit and discard all changes since then: git reset –hard
- Preserve all changes as unstaged changes: git reset
- Preserve uncommitted local changes: git reset – – keep
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
22 Nov, 2021
Like Article
Save Article