Hello everyone👋!!
In this article, I have mentioned how to create a repository on Github and write some basic git commands in order to add your local project to Github using the command line/ terminal or git bash.
This is the article for beginners🤩 who don't know what is Git and Github but want to learn the basics of creating a repo & adding the project to Github.
Do give it a read:)
📋Follow the steps along with me:
Reminder: If you haven't made a Github account, then make sure you have it.
⭐Creating a new repository:
- Open Github on desktop and on the right side you will find a + icon.
- Click that icon and you will get the first drop-down menu as "New Repository", click on that.
- By doing this you will be rendered to a new window asking your Repository name, description(optional), fill in all the details that are required.
- Further you are asked whether to keep the repo public or private, you can choose whatever you wish to.
- At last you are asked to add a readme file, .gitignore file, and choose a license. That's again optional.
I would suggest always add a readme file as it makes out your repo look more good & informative. Also, it is easy for others to understand what your project is about by reading a readme file.
⭐Adding an existing project to Github using terminal:
- Open a terminal in the current working directory (which has the project you want to add).
Initialise git repository by typing the following command:
git init
Add all the files and folders from your local server project to Github by writing a command:
git add .
Commit the files that you’ve staged in your local repository with a short & informational message.
git commit -m "Type your message...."
- Now, go to the GitHub repository that you have created above and copy the HTTPS URL.
In the terminal copy the following command:
git remote add origin "remote repository URL"
Here instead of remote repository URL, paste the URL of a new repo that you have just copied. Example:
git remote add origin https://github.com/Isha2103/abc.git
Next write the given command, this is used to connect your local repository to the remote server.
git remote -v
Now Push the changes in your local repository to GitHub.
git push origin master
After this command it asks you for Github username and password, type it and your changes are pushed to Github.
Refresh the Github window and you will see all the files and folders are added to the repo. And with this, you have added your project from the local server to Github.
Hope you find this article helpful🤩!!
Please leave your thoughts below and share this article with your friends.😇