Git essential commands
In this article we will explore git and some important commands to use Git. As you know Git is used for version control. There are some commands that are used by developers on daily basis while committing. Here are some useful Git commands.
Initializing a git repository. (To create a new git repository).
Lists all new or modified files to be committed
Shows the file differences not yet staged
Snapshots the file in preparation for versioning
Shows file differences between staging and the last file version
Unstages the file, but preserves its contents
Committing a file – File snapshots permanently in version history. We have to add a message describing the change made.
$ git commit - m "Added new registration form"
Sets the name you want attached to your commit transactions
git config --global user.name "name"
Sets the email you want attached to your commit transactions
git config --global user.email "email address"
Enables helpful colorization of command line output
git config --global color.ui auto
Start a new repository or obtain one from an existing URL
Creates a new local repository with the specified name
Downloads a project and its entire version history
Name a series of commits and combine completed efforts
Lists all local branches in the current repository
Switches to the specified branch and updates the working directory
Combines the specified branch’s history into the current branch
Deletes the specified branch
git branch -d branch- name
Register a repository bookmark and exchange version history
Downloads all history from the repository
Combines bookmark’s branch into current local branch
git merge bookmark/branch
Uploads all local branch commits to GitHub
Relocate and remove versioned files
Deletes the file from the working directory and stages the deletion
Removes the file from version control but preserves the file locally
Changes the file name and prepares it for commit
git mv file-original file-renamed
Shelve and restore incomplete changes
Temporarily stores all modified tracked files
Lists all stashed changesets
Restores the most recently stashed files
Discards the most recently stashed changeset
Erase mistakes and craft replacement history
Undoes all commits after commit, preserving changes locally
Discards all history and changes back to the specified commit
Browse and inspect the log history of project files
Lists version history for the current branch
file Lists version history for a file, including renames
Shows content differences between two branches
git diff first-branch...second-branch
Outputs metadata and content changes of the specified commit
These are some basic commands used by developers in their day to day work. thanks for reading and do visit again to have more inflammatory articles.