I don't want to bore you with an introduction to Git, i assume that you already know what Git is and what its used for. Its a very useful tool for programmers and developers
Table of Contents
Steps to Create a Git Repository
Create an empty repository in your GitHub account. You can leave readme and license which can be added later.
Suppose you have a project folder DEMO in your linux PC, Open the command line inside the folder DEMO and follow the below commands.
Initialise your local folder as Git repo
git init -b main
Add the files in your new local repository
git add .
Commit the files
git commit -m "Initial Commit"
Copy the repo URL
It would be something like this https://github.com/user/demo.git
Set the Git repo
git remote add origin https://github.com/user/demo.git
Verifies the Git repo
git remote -v
Push local repo to Git
git push origin master
Set remote repo to local repo
git remote add origin https://github.com/user/repo.git
Current Branch Info
git branch
List all branches in repo
git branch -a
Switch to another repo
git checkout branch
Conclusion
I hope that this article on "How to Manage a Git Repository in Linux Command Line" helped you to understand better about Git commands. If you think something is missing in our article please let us know.
You can freely comment on your doubts and queries below. If you liked this article, then please share this with your friends. You can also find us on Twitter, Facebook, YouTube, and Instagram.
No comments:
Post a Comment