Basically, GitHub is a Git repository hosting service. Git is a command-line tool, GitHub provides a Web-based graphical interface. It also provides access control and several collaboration features, such as wikis and basic task management tools for every project.
Let's begin contributing to an existing project.
Firstly, I need to download(clone) that remote repository to our local machine. (Use Git bash to run these all commands)
git clone (web URL)
eg: git clone https://github.com/SachithMayantha/recipe-app.git
Then we need to go to your local repository folder. Change into the repository directory.
eg: cd recipe-app
So, we need to create a new branch in this existing repository. Because we can't contribute to the master branch directly. (Because Repository owner is not me). Let's create a new branch to store our new changes.
git branch (my-branch)
Then we need to switch to that new branch. Because our all changes store in there.
git checkout (my-branch)
This is your chance to show your coding skill. Make changes. You can add, delete or edit any code in that project.
Then we want to add our changed files to our remote repository branch.
git add (file_name) - command use to add one specific file
git add . - command use to add all files
So, take a snapshot of the staging area (anything that's been added).
git commit -m "(can write anything)"
Finally, push changes to our branch of GitHub remote repository.
git push --set-upstream origin (my-branch)
I have to say a special thing about --set-upstream flag. When you push to a remote and you use the --set-upstream flag git sets the branch you are pushing to as the remote-tracking branch of the branch you are pushing.
Thank you.! Happy coding.! 😍❤