From clone to push!

From clone to push!

Table of contents

I have seen comments on twitter people complaining about Git like Git is so tough to understand and it's not their cup of tea. well I say git is not that tough and i'll make you understand it from initialising or cloning to pushing it to Github.

And this month of October brings you the golden opportunity to learn Git and Github because of Hacktoberfest. So you might be wondering what Hacktoberfest is ? Hacktoberfest is the yearly event which happens in the month of October to encourage people to contribute to opensource and if 4 of your pull requests gets merged you'll get a chance to avail some T-shirts, Stickers and plant a tree. For more pls visit Hacktoberfest

What is Git and Github?

  • Git is fast, scalable, Distributed Version control System and it is rich in commands.

  • Github is a code hosting platform for version control and collaboration. It lets you and other people work together on projects from anywhere.

In this blog we'll be learning Git commands to get started with

1.  Select the location of your choice  and open the terminal there and make a directory.

 mkdir folder_name

2. Go inside that directory

 cd folder_name

3. [Clone](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository) the repo inside the folder.

git clone url

4. Go inside the repo 

cd reponame

5. check the list of folders present over there

ls

6. Create a branch and switch to that branch

git branch <branch_name>
git switch <branch_name>

7. Open the files in another text editor and code editor and make some necessary changes

8. Check the differences using 

git diff

9. Now your branch should be in sync with the main branch

            git checkout main
            git pull

            git checkout <branch_name>
            git pull

    Note: It will ask which branch to merge the file

            use command:
            git branch --set-upstream-to=origin/<main branch> <branch name>
10. Adding the changes to git

   git add .

11. commit the changes 

git commit -m 'Type your message here'

12. Push the changes to Github

git push or git push origin HEAD

13. Enter Git username and Product key

Congratulations, Now you have successfully pushed it to Github!

I am Satyam Soni. I am a beginner started documenting my learning journey. More blogs on opensource, web Dev and Machine Learning will be published soon.

Thanks for reading the blog. Your feedback will be appreciated.