What is Github
- GitHub is a code hosting platform for version control and collaboration. It allows you and others to work on projects together anywhere.
- This tutorial will teach you the basics of GitHub, such as repositories, branches, commits, and requests. You will create your own Hello World repository and learn GitHub's Pull Request workflow, which is a popular way to create and view code
- To complete this tutorial, no coding is required, only a GitHub.com account and Internet access are required
Create and use repositories
- Repositories are often used to organize individual projects. The repository can contain folders and files, images, videos, spreadsheets and data sets, etc. It is recommended to include a README or a file containing information about your project
- Your hello world repository can be where you store ideas, resources, and even share and discuss things with others
Create a new repository
1. Next to the avatar or identicon in the upper right corner, click and select "New repository".
2. Name your repository hello-world.
3. Write a short description.
4. Choose to initialize this repository with README
Create a new branch
- Branching is a way of working on different versions of the repository at once.
- By default, your repository has a branch named main, which is considered an authoritative branch. We use branches to experiment and edit, and then submit it to main
- When you create a branch from the main branch, you are copying main, and if someone else makes changes to the main branch while you are working on the branch, you can pull those updates.
- The figure shows: The
main branch is
a new branch called feature (because we are doing "feature work" on this branch)
The journey that the feature branch has to go through before integrating into main
Have you ever saved files of different versions? It's like:
story.txt
story-joe-edit.txt
story-joe-edit-reviewed.txt
branch achieves similar goals in GitHub repository.
On GitHub, our developers, writers, and designers use branches to distinguish bug fixes and feature work from our main (production) branch. When they are ready to change, they will merge the branch into main.
Create a new branch
- Go to the new repository hello-world.
- Click the drop-down list at the top of the file list to display the branch: main.
- Type the branch name, readme-edits in the new branch text box.
- Select the blue "Create" branch box or press "Enter" on the keyboard
Now you have two branches, main and readme-edits. Now they look exactly the same. Next, we will add the changes to the new branch.
Start and manage new branches
- Now you are in the code view of the readme-edits branch, which is a copy of main. Now let's make some edits.
- On GitHub, saved changes are called commits . Every commit has an associated commit message, which explains why a particular change was made. The commit message records your history of changes, so other contributors can understand what you did and why.
Make and submit changes
Click the README.md file.
Click the pencil icon in the upper right corner of the file view to edit.
In the editor, write some information about yourself.
Write a commit message describing the changes you made.
Clicking the Submit Changes button
only makes changes to the README file on the readme-edits branch, so this branch now contains different content from main
Open pull request
- Now that you have made changes in the main branch, you can now open a pull request.
- Pull Requests are the core of collaboration on GitHub. When you open a pull request, you are making a change and asking someone to review and extract your contribution and merge it into its branch. Pull requests show differences or differences in content in the two branches. Changes, addition and subtraction are shown in green and red.
- After submission, you can open the pull request and start the discussion even before the code is complete
- By using GitHub's @mention system in your pull request message, you can ask specific people or teams to provide feedback, whether they are in the lobby or out of 10 time zones
- You can even open pull requests in your own repository and merge them yourself. This is a great way to learn the GitHub process before working on a large project
- Open Pull Request to change the README request
[1] Click the "Pull Request" tab, and then from the "Pull Request" page, click the green "New Pull Request" button.
[2] In the "Example Comparisons" box, select the branch (readme-edits) you created to compare with the main (original)
[3] View your changes in the differences on the "Compare" page to make sure they are yours to submit
[4] Once you are satisfied with the changes to be submitted, please click on the big green button to create a request
[5] Give your request a title and write a brief description of your changes.
After leaving a message, click "Create pull request"!
Tip: You can use emoticons and drag and drop images and gifs onto notes and "Pull Request".
Open and merge Pull Request
In the final step, it’s time to gather your changes together-merge the readme-edit branch into the main branch
- Click the green "Merge pull request" button to merge the changes into main
- Click Confirm merge
- Go ahead and delete the branch, because its changes have been merged, please use the "Delete branch" button in the purple box.
After completing this tutorial, you have learned to create a project and make a pull request on GitHub!
Check your GitHub profile and you will see the new contribution box!
To learn more about the pull request feature, we recommend reading the GitHub flow Guide . You can also visit GitHub Explore and participate in an open source project.