To know what is Git and what does it do. Kindly check out the last article What is Git, Why it is so important
Before getting into commands, there are a few terms to which you must be familiar.
Important Git Terminologies
Repository or repo is nothing but the collection of source code or files or projects
Working / Current Directory
The directory or folder in which you are currently working or where you have your latest code.
The branch is essentially a unique set of code changes with a unique name. It has its own copy of the project history and develops on its own code.
Creating a copy of a repository in your Git account to use the code or to make changes in it.
The clone is an action of downloading an existing Git repository to your local computer. You will then have a local version of that Git repo in your local machine to work.
Pull Request (PR)
Web-based way to submit your work (called “patches”) to a project. Suppose you made few changes in a project code, now you ask to pull those changes in the original project.
How to use Git
Make sure you download the Dekstop Github, if not click from here
Adding a project to new repo
You can use the command prompt or Visual Studio Code(VS Code)
to add a project from your local machine to GitHub.
- If using command prompt, change into the directory where your source code is located. And for VS code, open Terminal there.
- Create a new Repository and copy its URL.
- The commands to push the source code in the repo are written below the Quick setup, you can have a look at the picture below.
- Fork the repository to which you want to commit changes.
- Click on Clone and open the file in Dekstop GitHub (make sure you have downloaded Dekstop GitHub)
- Now, you can open the complete file in your local editor and make a new branch to commit changes.
- Push it back to your repo by using
$ git push -u origin new branchcommand.
- After pushing the commit, click on Compareand you will be taken to the original repo where you wanted to commit changes
- Write the description of your changes (optional) and click on Create Pull Request
- The maintainers/owners of the original repo can see your contribution and accept your request to merge with the source code.
I hope all the basics are covered in the last two articles. If it helped, do tell me here.
Okay bye! Have a good day :)