Here I will discuss about one of the major version control tools. Version control tool is one of the most needed software during application development. Here I will discuss GitHub basics for beginners with some GitHub basic commands.
Why we need the version control tool
- It is free of cost and open source.
- In the repository, we can store the code private as well as public mode.
- Distributed repository model.
- Capable to handle small to large-sized projects.
- Code changes can be tracked very easily and clearly.
- Download and install Git from GIT for windows
- Go to Git HUB web application and sign up.
- After installing the Git, you will find 3 icons like Git Bash, Git CMD, Git GUI.
- For the initial Git setting, open the Git Bash and now you will get a screen like below
$git config user.name "Your Name" $git config user.email "email@example.com"
In the name, input your user name and in the email input the email.
GitHub basic commands
In this GitHub basics for beginners tutorial I will discuss GitHub basic commands with repository creation, file push to the repository and pull from the repository
- Go to the Git-HUB web application.
- Login there.
- For creating a repository click on new
- Provide a repository name here, then choose as per your requirement, if you want to visible the code to all then in that scenario you can choose public else private. Here I have provided “MyDemo” as the repository name
- Then click on the “Create repository” button, Now your repository created successfully.
- Then click on your profile symbol dropdown(right top corner), Go to “your repositories” option, then click on that. Now you will find your newly created repository.
- Now you will get the list of the repository, click on the newly created repository and copy the link and save it on a notepad.
- Go to your folder explorer and create a folder. Keep a file there.
- Here My folder name is Bidya_Demo. I have kept a file named as “Test Test”
- Through the command prompt go to the newly created folder location.
- For initializing the local folder as a Git repository write the below syntax in command prompt.
- Here, I will add a repository, write the copied repository on the command prompt using the “git remote add origin” syntax like the below.
git remote add origin https://github.com/BidyaMishra/MyDemo.git
- Check the status of the local origin using the below syntax.
- Add the untracked files, using the below syntax.
git add -A
- Push the file to the repository using the below syntax.
git push origin master
- cd Bidya_Demo: Changed directory to the “Bidya_demo” folder.
- git init: Initialized local folder as a git repository.
- git remote add origin https://github.com/BidyaMishra/MyDemo.git: Added remote repository in the local folder.
- git status: Status checked and found one file has not added.
- git add -A: Added the “Test Test.txt” file.
- git commit -m”Added new file”: Committed the file and provided the comment
- git push origin master: Pushed the file to the remote repository.