As I completed that how to use github and what is the use of it, Its time to learn the commands of it.
1. First command is to check the version of the git. The command is git –version. This will show the current version of the git which is installed.
2. The next is git init. This will make the local directory to a repository.
3. git add. this will add the file to the staging area, but not to the local repository.
4. To add to the local repository, git commit is used. Normally each commit should be given with the message for the better understanding. This is done by -m “Message”.
5. git status, this command will show on what branch we are working on and displays if any files present in the staging are but not commited to the local repository.
6. git config, It is used to config our username and the email in which we can set global or local. git config –global user.name “Chandru”, git config –global user.email “r.v.chandru.13@gmail.com”
7. git branch, this command is used to display all the branches which are created and also used to create a new branch. To create a new branch git branch new_branch_name
8. git checkout branchname, this command is used to change from the current branch.
9. git merge branchname, this will merge the master branch and the branch which is given in the arguement.
10. git branch -d branchname, this command will delete the branch.
11. git remote add origin git@github.com:Chandru-RV/Chandru.git, this is used to add the remote repository.
12. git clone “SSH link”, this command is used to create a clone of the repository which is found in that link.
13. git pull origin master. In case in change made in the github repository, to reflect in our local repository, this command is used.
14. git push origin master. If we want to add changes or to add a new file to the github account, this command is used. We can push the changes to it only if we add and commit to the local repository and then push it.
15. git log. This command is to store the records of the author, who commited a file.
16. If we commited a change to existing file which is already commited and if you want to move back to the previously commited file and delete the recently commited file, git revert command is used. To start with this, first type git log –oneline. This will return alphanumeric value with a label last commit. Then copy the value and type git revert “alphanumeric_value”. After this, the recently made changes will be gone.
17. If you again want the previously commited changes, git revert HEAD command is used.