Git & Github complete guide for Newbies
Tags: Github, Git, Software Engineering, Software Development, Programming

What is Github?

It is a platform that provides facilities like code hosting, version controlling, code reviewing, managing projects from open source to business by collaborating with other developers.

Github Essentials

Git

Repositories

Branches

Commits

Pull Requests

What is Git?

Git is a distributed version control system Github is built on, It uses for tracking changes in any set of files. Originally it has designed for coordinating work between developers contributing to source code during the software development process.

What are Repositories?

In Github, you create repositories to store/host your code. Inside that repository, you can store folders and any type of files like HTML, CSS, Javascript, PHP, Python, Java, Document, Data, Images and etc. You can include a Licence file and README file about your project inside that repository as well. Repositories can also be used to store ideas or any resources that you want to share.

What are the Branches?

You can create branches inside the repository to work with different versions of your code/project at the same time. By default, a repository has a master branch. Any other branches that you are creating inside the repository called copies of the master branch.

Most of the time new branches are creating for bug fixes and feature work (Ex: SignIn / SignUp Feature) separate from the master branch. When the changes have been made, you can merge other branches into the master branch. If someone made changes on the master branch while you are working on another branch, you can pull those updates into your current branch.

What are Commits?

When you are working with a repository, you have to commit the changes you have done on that existing repository to make them permanent. Each commit (change) has a description explaining why a change was made.

What are the Pull Requests?

Pull requests are the most important part of Github collaboration. Using pull requests you can propose that your changes should be merged (pulled in) with the master branch. Pull requests show content differences, changes, additions, and subtractions in colours (green and red). As soon as you have a commit, you can open a pull request and start a discussion, even before the code is finished.

How to Start?

Create a Github account (Click Here) Download and Install Git (Click Here)

Need Beginner Practical Guidance?

1. Create a folder and open Git Bash inside it.

2. Create Files

3. Initialize Git Repository inside this folder

4. Add your Username and Email

5. Reset your Username and Email

6. Add ‘index.html’ file into the Staging Area (git repo)

7. See what are available in the Staging area

8. Remove ‘index.html’ file from the Staging area

9. Add all ‘.html’ files into the Staging area

10. Add all files into the Staging area

11. If we do a change while we in the Staging area

12. Default Commit

13. Make a change in ‘app.js’ file and add it

14. Commit by skipping the VIM editing section

15. Create and use ‘.gitignore’

Inside the .gitignore file, we add file and folder names that we don’t want to include into our git repo.

16. Create a sample file called ‘log.txt’

We are not going to include this file into the git repo.

17. Add this file name into ‘.gitignore’ file and then,

18. Add folders into ‘.gitignore’ file

Create 2 folders called, ‘dir1’ and ‘dir 2’. Inside each folder create a sample js file. Then add ‘/dir2’ into .gitignore file.

19. Create a branch for ‘login’ feature

20. Switch to ‘login’ branch and create ‘index.html’ file

21. Again Switch to ‘master’ branch

When we switching again to master branch, in code editor all the changes and files will be gone, because that is in the ‘login’ branch.

22. Merge ‘login’ branch into the ‘master’ branch

23. Working on Remote repositories

Log in to GitHub and create a repository then they will display some steps. We are already done some of them, just start from this step.

24. Push Local repository into that Remote repository

25. Change the Remote repository

26. Add a ‘README’ File

27. Clone a Project

28. Pull Request

Fetch and download content from a remote repository and immediately update the local repository to match that content

References