github is a very useful version management tool. I am learning how to use github for collaborative development recently, so I will summarize the process and some operations.
The blog post includes:
1 Project configuration work of the team leader
2 Project initialization
3 Project update
4 Project version rollback
5 Process Mind Map
The project configuration work of the team leader:
1. The captain creates a new organization, invites team members, and sets their permissions to owner; log in to github → Settings → Organizations
2. Each team member obtains the SSH KEY (open the terminal)
ssh-keygen -t rsa -C “[email protected]” cat ~/.ssh/id_rsa.pub
3. The captain adds the SSH KEY of the player
Project initialization:
1. Initialize the project folder,
git init
2. Add and modify
git add .
3. Submit the modification and add a description to your modification
git commit -m "your_description"
4. Add remote warehouse
git remote add origin htttps://github.com/your_repo.git
5. If the warehouse exists, use the following command to delete it, and then re-add a new remote warehouse
git remote rm origin6. Publish the project under master
git push -u origin master
Project update:
1. If the project does not exist locally, use the following command to download the project
git clone http://github.com/your_repo.git
2. If the project already exists locally, use the following command to update the project (download the modifications of other players)
git pull
3. Project modifications such as: adding files or modifying the file code
4. Check whether there are uncommitted modifications, if there are red files, add commits through git add & git commit
git status
5. Create a new branch. In order to avoid direct modification of source files, it is necessary to create a new branch
git checkout -b your_branch
6. View the current branch
git branch
7. To submit a branch, you need to enter the github account password
git push origin your_branch8. Go to the github account to create a pull request. After the captain or other team members check and agree, the project can be integrated
9. Use the following command to return to the corresponding branch. This is a powerful function. The author also accidentally discovered that: after using this command to switch branches, the content of your local github folder will be transformed into the corresponding content under the branch (such as back To the master branch, roll back and modify the content under master)
git checkout your_branchname
Project version rollback:
1. View the version number corresponding to the submitted modification (push)
git log
2. Roll back to the version with the specified version number
git reset --hard version
Or, roll back a version
git reset --hard HEAD^
rollback n versions
git reset --hardHEAD~n
(Use this command with caution, the modifications will be erased)
Process mind map:
Reference site: https://product.hubspot.com/blog/git-and-github-tutorial-for-beginners
If there are any mistakes, please advise
Contact: [email protected]