You have made a project, Great ! But is it available online ? I mean is it accessible from anywhere or only in your machine. Well, I guess only in your machine. Okay, what about submiting it online. Yes the way you put your photos from your mobile to cloud called Google Photos. It gives you access of your photos from anywhere in the world. Similarly there is a place where you can submit your codes in the form of repository. Sounds Good! isnt it? Github is that powerful dev platform, opensource community, version control system where you can submit your projects, codes in form of repository.
Git is the version control system. It's even more powerful than you think. It will track your changes which you did in your files so that you have the records of what you did and you can go to specific versions too. You can collaborate, merge with multiple no of people and and finally merge in main.
Here We will be focused on Git commands.
For this, lets suppose you have a folder say "yourname-site" having two files in it namely index.html and readme.md, now in order to publish its first version open your gitbash or if you are using VS Code then do Ctrl+` This will open your terminal
Check the path if its correct then awesome, otherwise navigate to the folder you wanna push
For this simply type git --version
Do run the first command 'git init' - It will initialize a new git repository for you or will convert a existing repository In our's case an existing one will be converted : )
this command adds a file in the staging environment.As a developer you will be adding,editing and removing files.Adding files will make you ready for the files to be committed
for adding all file do git add .
Now as stage is completed we can move to commit. adding commit will keep track of your progress and changes. As you will do it everytime you add , delete or edit file its important to keep track for this we always include a message while do'in commit.
So do type git commit -m "First Commit"
and yaay!! You are ready to go for pushing your files on github. btw, have you noticed the switch -m ??
It adds the commit message
You can also do branching that's the power of GitHub.If you have a large project you will give replica to every member and they will have their own branch where they can submit their codes without affecting the original files.Once completed people can always check and verify and if all good can merge to original file which we call main branch but for that atleast we first need to make a main branch
So for this type git branch -M main
and boom main branch created.
Haha!!
Before you push you must know where to push na?? Go to your github account and then make a new repository naming "studentname-site" and then click create repositoy there you will also get remote url copy it and run this command
git remote add origin https://github.com/gitAccount/studentname-site.git
Yes the time came. This command will push your local repo to the remote in GitHub
for this type git push -u origin main
Your first repo pushed. Go and check it in your repository section in your github account.
for now Bbye Happy coding!