How to set up a local Git repository to a remote one. — Daniel Anomfueme
Published on Jun 2nd, 2020 02:58 AM
Before we proceed let’s get to know what Git really is. According to Wikipedia, “Git is a distributed version-control system for tracking changes in source code during software development. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files. Its goals include speed, data integrity, and support for distributed, non-linear workflows.”
In simple terms, think of it as your life, yes your life. You get to create an event (your local repository), you can decide to share that event with others by going live (pushing to your remote repository) but the cool thing about it is that you can rewind time. Yeah you know how we tend to wish we could go back and correct a mistake we made? Yeah, with git this is possible. So enough of the talk and let me show you how I went about Task 0.5.
Firstly I created a new local git repository. The command to create a new repository is “git init “, this simply tells your computer to create an empty git repo. Next was to create the README.md file, I did it through the terminal way of creating such files. The file has been created but git is not yet aware of it. It’s not like git doesn’t know you created such a file, it’s just that you haven’t instructed git to track the file. So we use “git add “. Now it is aware and tracks the README.md, it notices the changes in this file but you have to instruct it when it should commit such changes to git. We do that using “git commit -m “message” “. You are free to specify any message as commit message, usually it’s about features added or bugs fixed in projects.
That’s it, your local repo has been created with a README.md file committed. You can now go to Github and create your remote repo( don’t add a README.md again). Once the repo is created, mine is https://github.com/LifeofDan-EL/HNG7Task1 (renamed to this), it’s left to hook it up to the remote repo. To do use “git remote add “ the url being the Github url. Doing so connects your local to repo to your remote, now finally we need to send the changes made locally to the remote repo. We do that with, “git push -u
That’s it, everything is working, thanks for reading. Apologies, the whole article would have been clearer with images but I keep getting “Internal Server Error” anytime I try to publish it.
Originally published at https://lucid.blog.