This is the sixth day of my participation in the November Gwen Challenge. Check out the event details: The last Gwen Challenge 2021

As rookies put it: “If you’re a Coder, but you don’t know Github, then I don’t think you’re a Coder, because you’re not really a Coder, you’re just a Code porter.”

1. Dead simple introduction

Github is a Git-based code hosting platform. Paying users can set up private repositories, while our regular free users can only use public repositories, i.e. code is made public.

Today, GitHub is:

  • A community of 1.43 million developers. There are top hackers like Torvalds, the Linux inventor, and young geeks like DHH, the Rails founder.
  • The most popular open source hosting service on the planet. At present, 4.31 million Git projects have been hosted on GitHub. More and more well-known open source projects have moved to GitHub, such as Ruby on Rails, jQuery, Ruby, Erlang/OTP. Popular open source libraries such as BootStrap, Node.js, CoffeScript and so on are released on GitHub.
  • Alexa ranked 414th in the world.

2. Register and use Github

The first step to using Github is to sign up for a Github account. To Create the Repository (free users can only build public repositories), Create a New Repository, fill in the name Create, and the Repository configuration will appear.

Configuration making

What do we do before we clone the library? We first have to generate the public key and then copy it to GitHub before we can use GitHub’s code management capabilities.

(1) Create an SSH key locally.

ssh-keygen -t rsa -C "[email protected]"
Copy the code

The following [email protected] is changed to the email address you registered on Github. After that, you will be asked to confirm the path and input the password. In this case, we just use the default enter. SSH folder, go to id_rsa.pub, and copy the key inside.

Go back to Github, go to Account Settings, select SSH Keys, Add SSH Key,title, paste the Key generated on your computer.

(2) Verify that the key is added successfully

 ssh -T [email protected]
Copy the code

If it is the first time You are prompted to continue or not, type yes to see: You’ve successfully authenticated, but GitHub does not provide shell access. This means you have successfully connected to Github.

(3) Upload the local warehouse

You also need to set username and email before doing this, because github records them every commit.

git config --global user.name "your name"
$ git config --global user.email "[email protected]"
Copy the code

Go to the repository where you want to upload, right-click git bash and add the remote address:

git remote add origin [email protected]:yourName/yourRepo.git
Copy the code

You can add yourName and yourRepo to your github repository, go to.git, open config, and find the remote “Origin” address. You can also modify config directly to configure the remote address.

Create a new folder, open it, and then execute git init to create a new Git repository.

Check out the warehouse

What if instead of a repository, you want to download someone else’s code? Follow this process:

Execute the following command to create a clone of the local repository:

git clone /path/to/repository 
Copy the code

If it was a repository on a remote server, your command would look like this:

git clone username@host:/path/to/repository
Copy the code

Finally, the use of Git to manage the code, about the use of Git advice to refer to ruan teacher’s article commonly used git command list

3. Participate in other open source projects on GitHub

1. We’ve always used GitHub as a free remote repository, but if you can, you can pay to contribute to the open source world.

If it is your own open source project, you can put it on GitHub without any problem. GitHub is also an open source collaboration community that allows people to participate in both your open source projects and others’ projects.

So how do we participate in an open source project? For example, the popular jquery framework, you can visit its project homepage at github.com/jquery/jque…

Pay attention to

  • Clone repositories must be cloned from your own account so that you can push changes.

If the author from the jquery warehouse address [email protected]: jquery/jquery. Git clone, because do not have permissions, you will not be able to push changes. If you want to fix a bug or add a new feature to jquery, I would say you can start developing it now and push it to your repository.

  • If you want the official jquery library to accept your changes, you can start a pull Request on GitHub. Of course, the official acceptance of your pull request may or may not be

4. Functions of Watch, star and fork

watch

By default, every user is in the state of Not watching. When you choose watching, it means that you will pay attention to all the dynamics of the project in the future. In the future, as long as the project changes, for example, someone submits a pull request, someone initiates an issue, etc.,

You will receive a notification message in your personal notification center, and if you set up a personal email address, your email address may also receive the corresponding message

As follows, I watch the open source project Android-cn/Android-discuss, so anyone who submits an issue under this project or leaves any comment under the issue in the future,

My call center will call me. If you have email configured, you may also receive emails constantly.

star

When you click on the star, it means you like the project, or more generally, it can be interpreted as a “like” in the circle of friends, indicating your support for the project.

Github has a list of all the projects you’ve started.

Click on the Github profile picture to see the entry of your Star. Click on it to see all the projects you have starred in. The following figure

fork

When you fork, you have a copy of the original project. Of course, this copy is only for the current project file. If the original project file changes later, you must synchronize it by other means.

In general, we don’t need to use fork unless there are some projects that have bugs or things that can be optimized, If you want to help the author of the original project to improve the project or simply want to maintain a project of your own based on the original project (for example, I fork the AndroidWeekly client, then you can fork a project and modify the project by yourself. When you think the project is ok, You can then try to make a pull request to the original project author.

Then I waited quietly for his merge email notification.

I see a lot of people using the wrong fork. Many people use fork as a bookmarking feature, including me who started using Github and forked every time I saw a good project,

Because of this, I can view the fork project in my Repository list. You can use star to do this.

5. How to learn from great people on Github

Instead of looking up at the bullies inside the walls, go straight to GitHub:

  • Watch, fork cattle
  • Submit pull Requests for their projects
  • Volunteer to write wikis or submit test cases or questions for people’s projects
  • We can also help them translate Chinese

Where is the bull man?

  • GitHub’s codebase itself: in particular, Explore and the Popular Information library
  • GitHub official features: GitHub’s own blog and GitHub staff’s personal blogs feature projects and developers
  • All the GitHub repositories mentioned on social media: Hacker News in particular.

Github is also where many of the best people started to document their learning journeys. There are even technical books on Github, such as javascript You Didn’t Know.

Today’s share is over here, I hope to help you.