GitHub is a platform for code hosting that lets you to collaborate and work together with your friends in different projects. To understand GitHub you must have the knowledge of “GIT”. Git is basically a open source version control system, it means when developers create an app or any other project, they make constant changes to the code and build new versions. Version control system helps them to keep these changes and storing the modifications in a central repository.
Why we need GitHub ?
We need GitHub because it is like a cloud for code. We can also use it as a showcase for our work. Because most companies look into the GitHub profiles when they are searching new recruits for their projects. We can also make constant changes in our code in different projects and GitHub keep storing these changes for us.
How to create an account on GitHub ?
First of all you need to go on GitHub website using the link given below
GitHub: Where the world builds software
GitHub is where over 50 million developers shape the future of software, together. Contribute to the open source…
Now, Go to sign up option and fill the create account page. Make sure you gave a valid email. Then, go to create account. You’ve successfully created your account.
What is repository ?
Repository means “A central location in which data is stored and managed”. In GitHub repository is a folder for your project. It contains all the files of your project. You can also make changes to your files.
How to create a new repository ?
To create a new repository go to up right corner and click on ‘+’ logo. Then chose the option of New repository.
Then name the repository, give description if you want but it is suggested that you should give description because it helps others to understand your project. Then make it private/public it’s all up to you. Click on create repository. You’ve successfully created your repository.
How to Push your files to your repository ?
First of all on your terminal enter to the directory where your project is stored. Now run following commands to push your project into the repository.
Now run the command to add file you want to add. If you want to add specific file you have to gave name of that file. I want to push all my files, so I use ‘git add .’ command.
git add .
Now run command to commit means changing your file. Every time you do changes in your file you have to commit and add some meaningful comment.
git commit -m "first commit"
Now if you want to add branch in the repository. Branch in GitHub uses to create another branch of repository. Because in this you can make constant changes in the code and then you can merge it with the main code.
git branch -M main
Now run command to connect your local directory to the repository on which you want to push your Project. You can also give a unique user name in the command. I have used URL in this command.
git remote add origin https://github.com/Subhan-khaliq/Dummy.git
Now push your files into the repository.
git push -u origin main
There it is you’ve successfully push your project. You can also add ‘read me’ file where you can add ‘how-to’ information about your project.
How to upload files on your repository ?
It’s another way to add your files by uploading it directly on repository.
First of all open your repository and go to add file option and choose upload files.
I’ve upload file with the name “inheritance.java”. Now, commit this file and give comment to this commit. Then choose option for commit to main branch or create another branch. I’ve choose commit to main branch. Then press commit changes button.
You’ve successfully upload file directly without terminal.
How to clone a repository ?
Clone creates a local copy of your repository. By this you can easily edit your changes locally rather than on the source files of your repository.
Go to up right corner and press the code option. Then copy the URL and open the terminal. Go to the directory where you want to clone. I’ve given the URL of my repository.
Now, run the following command to clone your repository.
You’ve successfully Push and Clone your repository using Terminal and by directly on your repository.