I've heard about GitHub before, but not in-depth learning, recently learning about Git and GitHub, and really getting to know why git and GitHub are generating And why the project was developed using Git and GitHub. For a long day of git and GitHub, maybe you have the same question, what's the relationship between Git and GitHub? It's popular to say that GitHub is a git online repository that's easy for many people to collaborate on, and Git is a local version control tool. From this point of view you can also understand the causes of git and GitHub, when you do development in the company, the work is done locally, it may take multiple fallback changes, the final modification after submitting their own results to GitHub, and then the same development team can view your changes, Download the modified project, and then do further development, everyone to do this, the project step by step to complete, and every time who modified, how to modify the record, if you feel the change is not good can be rolled back to the previous version. That's what git and GitHub are all about, and think that if you don't have git and GitHub, you'll have to back up one copy before each change, and then copy it again, and the other people on the same team want to see your changes. So git is developing the Linux kernel, and maybe they just came across the problem to develop the tool. Here is a common command flowchart of Git, through which you can get a more visual grasp of Git's use of the process, where the remote repository is often said GitHub, of course, it can be other
Generally the development project or everything has a working directory, such as my working directory is Git-demo, When you want to turn a directory into a git directory, use git init command, he will create a. git directory with some versioning information stored inside it. For example, you add some files in this directory or modify some files, you can use git add <filename> command to store it to staging area (Stage), if you confirm the modification, you can pass over git Commit-m the "interpret information" is submitted to the local repository (Repository), you have completed the local commit operation, of course, in which you can git status View the current status by git diff View modification comparison by git log View the status of the repository through the git --hard commit-id resets the head pointer for version fallback.
Once the local modifications are complete, you can push them to GitHub, and you'll need to associate the corresponding GitHub account with the SSH password before you push it:
1. Run in local git shell$ ssh-keygen -t rsa -C "[email protected]"
2. In the user's home directory (Windows such as: User/adminstrator). ssh folder, add SSH key under GitHub settings of corresponding account, copy key to id_rsa.pub content.
Now we can link to an existing repository in GitHub, using the command git remote add origin [email protected]:username/git-demo.git, Of course, you can also use the HTTPS protocol for delivery.
You can then push the master local repository to remote GitHub via Git push-u Origin master . If you want to reestablish a new remote link, you can first disconnect the current link using the command git remote RM origin and then relink. Now you can push your project to the remote Web repository.
Of course, we may sometimes have to copy from GitHub and make changes, and we can use git clone [email protected]:username/git-demo.git Copy to commit after the change. The illustration shows
Of course, our teammates may have to submit new changes before we can use git pull to synchronize remotely, and then make changes on a new basis.
At this point a complete git process is gone.
git checkout-b <branchname> to create a branch and jump, you can do the normal development on the branch, after the development is completed, and then back to master (with checkout) Merge this branch of the development successfully with git merge <branchname> after work on the branch is complete, you can delete the branch using Git branch-d < Branchname> a life cycle of branch has been completed, of course, git merge is recommended with--NO-FF parameters, such as git--no-ff- M "description" can record each merge.
One more important command is git stash, when you're not done with a branching development, and then you don't want to commit, and suddenly there's a shift to another branch, you can use Git stash to stage your current working state (like an archive). It is not too cool to read a file to continue working after a sudden mission, yes, it is. You can use the git stash list to view the current archive and use git stash pop to read the top task to continue working.
The label is equivalent to a release version, when you need to use git tag on a branch <name> create a tag,-M can add comments, you can use git push Origin <tagname> push a tag to GitHub, use git tag-d <tagname> Delete a tag.
References: Liaoche git tutorial, git official tutorial, git and GitHub distinction
Git Learning Summary