If you don't know about Git-GitHub and wanna getting started, then this may be a good starting guide for you. I will explain it in a very simple language.
but, first of all, you shoul have a basic idea of what Git and GitHub are!
What is Git <>?
Git is a Version Control system that maintains the log of your projects (Code) and tracks the changes as you update the files or contents within the file. Git also comes with Branching where you can create the branches to avoid any problems in the main code.
What is GitHub<>?
GitHub is a project hosting & management platform which comes (works) with git. You can put your code online on GitHub to share it with the world or your team members to collaborate on it. GitHub is so popular that most of the open-source projects are on GitHub & the community contributes to it.
Now you know what is git & GitHub. Now let's move ahead to know how it actually works. There are two main methods of working with Git-GitHub,
With GitHub Desktop App
With Command Line Interface / Terminal
Here we are gonna see the CLI method ...
Before starting ,
- Download Git from Here
- You can use any terminal for this (Cmd, Bash, Powershell, etc). Let's begin...
Initializing a git repository
You need to initialise the git repository which will store all your tracking information & logs.
CD into Project Folder
cd <Folder Name>
Initialize the git repo
git init
Start Tracking Files
You need to start git repo to track files for that you need to add files to the staging area to track.
git add <filename>
You can also add all files once,
git add .
Now all the files now being tracked
Your First commit
The commit is like a taking snapshot of the stage which will be stored in log files. Once you are done with all changes & ready to take Snapshot, commit your changes
git commit -m "<commit message>"
If you don't use -m, git will open a vim editor (you can select which editor you prefer while running the installation of git) for you to enter the commit message.
Now your changes are ready and you can upload your project to GitHub with all tracking information.
Let's see how
Add Remote Repo
For uploading files to GitHub you need to create a repository on GitHub (You can create it by clicking on create repository button)
Now you have a remote repo, to push local changes to the remote you add a remote
Git remote add <remote name> <remote url>
Push to Remote Repo
Push your all local files to remote
Git push -u <remote name> <upstream branch name>
Congratulations, you have successfully uploaded your project to GitHub with all tracking information such as commit messages, changes, log, etc
This was a beginner guide to publish your first project to GitHub. I hope it was fun. This is the most simple thing you can do with git-GitHub, there are lots of things you should check such as CI/CD with GitHub actions, GitHub pages etc.
To explore all power of Git & GitHub feal free to google & you will find tons of resources.
Let me know your thoughts on this post. I tried to explain in most simple manner. I hope you liked it!
Also, any suggestion or feedback is always appreciatedπ.
Follow me on Twitter
Top comments (0)