Have you ever heard about GitHub ? GitHub is how people build software. According to GitHub “We’re supporting a community where more than 21 million people learn, share, and work together to build software.”
According to Wikipedia “GitHub is a web-based Git or version control repository and Internet hosting service. It offers all of the distributed version control and source code management functionality of Git as well as adding its own features.”
In My word, Github profile tells about your programming journey.What you have learned and developed throughout your career in Coding.So, Why don’t you make your account on GitHub and start development?
<h2>Basic GitHub Command</h2>
In this article, we will start with basic GitHub command from beginning.First of all, if you are using MAC-Os or LINUX then your command will run on the terminal.But for window user, the instructions are as follow:
- Download git 32-bit Git for Windows Setup. or 64-bit Git for Windows Setup
- Install setup file and Launch the Git.
You will see this type of interface or similar UI.
PWD: present working directory, it is used to find out that this terminal uses which folder or directory.
so try it on git.
git clone "https://github.com/hasectic/No.-of-chocolate-problem"
Syntax git clone “URL or Path”
git clone is used to copy the file, folder or program from Github.com into your system.
When you make your profile at GitHub, then GitHub make a repository using your username like https://github.com/hasectic/ as my username is ‘hasectic’. In that repository, we can make the project or program. So, git clone “https://github.com/hasectic/No.-of-chocolate-problem” will copy the ‘No. of chocolate problem’ in your system. you can use git clone for your repository.
ls is used to display files and folders that are available in PWD(present working directory) Now.
you can see that ‘No. of chocolate problem’ ‘is also available after ls command.
cd is used to change the directory,so here in this code we have cloned No. of chocolate problem from GitHub so we changed the directory.
in the above picture we used cd and ls command. You are very smart enough to discover why i used ls.
we can make multiple branches for 1 repository,main branch is known as ‘Master‘ . we should make multiple branches due to backup recovery or rollback. if we want new modification in code or file we create new branch for it, then after proper validation verification we merge it into Master.
git checkout -b T1
If we wanna create new branch ‘T1‘ then we use git checkout -b T1, checkout is also used for switching between branches.
in this picture you can see there is * in front of T1, it means we are working in T1 branch, it will not affect Master Branch.
checkout and branch
We Should take care when we use checkout, because your checkout and * will decide which branch is modified.
Above picture will give you the idea, how we can switch branches and check it using *.
If we want to create a new file ‘new.txt’.Then we can use this touch command.
we want to modify prog.c so, we use notepad for it. you can use anything using mouse click copy and paste
Status commit and push.
We know that file is modified or a new file is created but it is not uploaded or pushed on GitHub. git status is used to check that file is uploaded or not on GitHub
git add prog.c git add new.txt
We add prog.c and new.txt in T1 Branch.
now you can detect git status command, the modified prog.c is green but before add command it was red.
git commit -m "gave some comment in prog.c"
commit is used to Record changes to the repository.
by using ‘git add’ to incrementally “add” changes to the index before using the ‘commit’ command (Note: even modified files must be “added”)
If you make a commit and then find a mistake immediately after
that, you can recover from it with ‘git reset’.
git commit -m “message”
here -m “message ” is necessary because it will define or describe what you have edited or created.
git push origin T1
now we want to push T1 branch to GitHub, here we will need login and password for that. You can see it in your git terminal.
That’s all for the day, enjoy git enjoy coding and play to feel you can say i have a coder in me.
Video tutorial for this article is also available
All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme