What Is Git?
GIT is software that comes with your computer and is installed on your computer if you have Mac or Linux. However, by default, it's a wrapper around the command line tools installer. Establishing Homebrew can make your life easier on mac. for more details on installation, please visit this link git-scm
Let's Go and discuss how this thing works!
Let's create a folder called Git, and then I will make an index.HTML file, APP. CSS file. Now, if one of these files gets deleted, I didn't save my progress. It’s gone forever. I don't know what was there in the file. If I wrote a bunch of HTML or CSS, one of the files gets deleted. I will lose my work. I can't do anything about it. But if I use Git, I will save them with the contents of these files, and when one gets deleted, I can go back to my saved progress and restore it. To use Git, you have to know a few commands. There are only a few, and it's not hard to understand.
git-init- Create an empty Git repository or reinitialize an existing one.
The first one is initializing your folder or project with Git. To do that, Just type git-init You now initialized an empty git repository. Great!!! That's the same thing as putting a memory card into your system because you obviously can't save the files without memory.
git-add - Add file contents to the index.
Now we want to save our progress. How do we do that? Well, git-add is what you need to protect our work progression. Meaning all of our changes since the last time we saved, or we could save a particular thing, so after (git-add), you want to put a file that you want to save, or I can save everything by using (git-add .) I would save everything I've done since the last time I saved. I rarely commit a specific file; I usually push changes on everything, so in 95% of cases, I will use (git-add .)
git-commit - Record changes to the repository
It commits the changes to memory, so you type git-commit, and then you need to do – M (stands for message) and describe the changes you will make. This way, when we go back on this saved progress. We know what we've done, so make a sensible and relatable message about what you're saving. for an example git-commit -m 'add java file and delete CSS file'.
git-log - By using this command, you can see the history of commits.
The detailed information of date and time, the entire record of a specific commit.
git-ignore - Specifies intentionally untracked files to ignore.
This command helps to ignore the files or folders you don't want to include in your repository. So even if we do (git-add.) Where it adds everything. It will not add those mentioned files inside ignore file.
What Is Git Hub?
Git hub is a website. Github It's the same thing as Bitbucket or GitLab. They are the websites where I just put the stuff from my computer to their website over the Internet so that other people can download my code and then go through all my projects. They could go back and forth. Jump through time loops to see all my code and do whatever they want.
So the question is, how do you get your code onto GitHub? Well, you make it a GitHub profile and make a repository. A repository is like a folder. You create a new repository on your profile, give a name, and provide some description. You also have an option to call public or private. Upon your selection, it gives you instructions to hook this thing up. You can use
readme.md, a markdown file that makes your project look more beautiful.
## Create a new repository on the command line touch README.md git init git add README.md git commit -m "first commit" git remote add origin email@example.com:alexpchin/<reponame>.git git push -u origin master ##Push an existing repository from the command line git remote add origin firstname.lastname@example.org:alexpchin/<reponame>.git git push -u origin master
git remote add origin <url>
It tells me how to do it. It gives you specific instructions. It says
git remote add origin <url> By using this command to hook it up to the website, I added the origin, which means I gave the directions on where to go.
git push -u origin master
This is called a push. So you have your saved commits to save progress, and then you push it to the website.
Now you can go back and check your new repository. Bingo! It's all there; all your HTML and CSS files appear here, whatever you have created.
There's a lot more to learn on GIT and Git hub. This is for beginners, like an intro. For more details, please refer to GitHub's official documents. Click here Git Docs
That's it all, folks... Keep Learning & Keep Sharing !!!
Did you find this article valuable?
Support PRAVEEN ALLURI by becoming a sponsor. Any amount is appreciated!