Open Terminal(Mac) or command prompt(Windows) and change directory to your project working directory.Then enter these commands :-
Git Command | Description | Recommendation | Note |
---|---|---|---|
|
This command sets the author name and email address respectively to be used with your commits. | Highly Recommended | This config is only needed for first time user. |
|
This Command will initialize the local Git Repository for your project. | Highly Recommended | This is the first command needed for every project. |
|
This command is used to obtain a repository from an existing URL. | Recommended | This is used when we want a copy/clone of a project/repository on our machine |
|
This Command will add a file to index or staging area. | Not Recommended | This is used when we want a single file to be indexed |
|
This Command will add the entire directory recursively, including files whose names begin with a dot. | Not Recommended | This command stages all files including .files which we may or may not want to stage. |
|
This Command will add all files in the current directory, except for files whose name begin with a dot. | Highly Recommended | This command stages all files excluding .files at one go |
|
This Command will commit the staged files.This command also takes a short/brief message about that particular commit | Highly Recommended | Meaningful commit message is recommended as it helps other developers/contributors/visitors to understand about that commit. |
|
This command commits any files you’ve added with the git add command and also commits any files you’ve changed since then. | Not Recommended | This opens Shell, which might get overwhelming if you try to understand it now. To close Shell, enter Escape button on keyboard and then type ":q" then Enter. |
|
This Command will show you the status of the current working tree. | Highly Recommended | This command will help you at every stage. Alway check status before pushing the repository to the GitHub |
|
This command shows the file differences which are not yet staged. | Highly Recommended | This command will help you identifying the difference by coloring the staged/not-staged lines with red and green and also with plus/minus symbols. When you are done, you can press the "q" or ":q" key to quit. |
|
This command shows the differences between the files in the staging area and the latest version present. | Recommended | This command will help you identifying the difference by color red and green and also with plus/minus symbols. When you are done, you can press the "q" or ":q" key to quit. |
|
This command shows the differences between the two branches mentioned. | Recommended | This command will help you identifying the difference by color red and green and also with plus/minus symbols. When you are done, you can press the "q" or ":q" key to quit. |
|
This command unstages the file, but it preserves the file contents. | Recommended | This command will remove the particular file from stage area. |
|
This command undoes all the commits after the specified commit and preserves the changes locally. | Recommended | Use this command if you know what you are doing. check status of the changes to keep track. |
|
This command discards all history and goes back to the specified commit. | Recommended | Use this command if you know what you are doing. check status of the changes to keep track. |
|
This command deletes the file from your working directory and stages the deletion. | Recommended | Use this command if you know what you are doing.Check twice which file you are about to delete. Check status of the changes to keep track. |
|
This command is used to list the version history for the current branch | Highly Recommended | Also Check status of the changes to keep track. |
|
This command lists version history for a file, including the renaming of files also. | Highly Recommended | Also Check status of the changes to keep track. |
|
This command shows the metadata and content changes of the specified commit. | Highly Recommended | Also Check status of the changes to keep track. |
|
This command is used to give tags to the specified commit. | Recommended | A lightweight tag is very much like a branch that doesn't change — it's just a pointer to a specific commit. |
|
This command lists all the local branches in the current repository. | Highly Recommended | useful when working in a team |
|
This command creates a new branch. | Highly Recommended | Alway create a branch if you are not sure about feature you are about to add. |
|
This command deletes the particular branch. | Highly Recommended | Delete branch when you have merge the feature with the master branch |
|
This command is used to switch from one branch to another. | Highly Recommended | Branching the project feature and the merging it, is very helpful. |
|
This command creates a new branch and also switches to it. | Highly Recommended | Branching the project feature and the merging it, is very helpful. |
|
This command merges the specified branch’s history into the current branch. | Highly Recommended | Branching the project feature and the merging it, is very helpful. |
|
This command is used to connect your local repository to the remote server. | Highly Recommended | Default Remote is "origin" but you can change as per your preference |
|
This command sends the committed changes of master branch to your remote repository. | Highly Recommended | Default Remote is "origin" and default master branch_name is "master" but you can change as per your preference |
|
This command sends the branch commits to your remote repository. | Highly Recommended | Default Remote is "origin" and default master branch_name is "master" but you can change as per your preference |
|
This command pushes all branches to your remote repository. | Highly Recommended | Pushes all new updates to the server's repo. |
|
This command deletes a branch on your remote repository. | Recommended | Use this command if you know what you are doing.Check twice which file you are about to delete. Check status of the changes to keep track. |
|
This command fetches and merges changes on the remote server to your working directory. | Recommended | Basically updates and merges the changes on your local repo |
Don't be frustrated with all this commands.
The best way to learn, is to make lots of mistakes.