Complete git and github study notes

Recently, project code needs to be submitted frequently, and it is obviously unrealistic to put the master on Github every time, so I want to learn git and github tutorials, but the online tutorials are relatively cumbersome. So I made a note of Wu Piqi’s B-station video as a memo.
Episode 1: Git is distributed version control software. The evolution process is constantly updated files -> local version control (only one is local, historical versions are saved using git's own database) -> centralized version control represents the software svn (the difference from local is that a server is used to store historical versions) -> Distributed version control tool (versions are retained locally and on the server, submitted as needed)
Episode 4: Process: Enter the folder to be managed (enter) -> Initialization (nomination) -> Management -> Generate version
Git bash here ->git init uses git to manage the folder where it is located. The .git folder stores git storage and version information. Git status detects the status of files in the current folder. Red indicates unmanaged new files or modified files, green indicates managed files, and colorless indicates that a version has been generated. Git add index.html Files to be managed, git add . Manages all unmanaged files in the current folder. Generate the version git commit -m "description information of the first version". After generation, the git status is empty. Afterwards, git status can detect changes to the folder contents. At this time, git add. Then git commit -m "description information of the second version", you can also use git log to display
Episode 5: Configuration, just follow the teacher's instructions. I have solved it before. Git config –global [email protected] git config –global user.name “lz”
Episode 6: Three major areas of git, workspace: staging area: repository: workspace is divided into managed and new, this It will be automatically detected after git init. Use git add to submit to the temporary storage area. You can use git add. You can also use git add., submit to the repository using git commit
Episode 7: git reset –hard version number. Roll back to the current version number. At this time, git log cannot display the rolled back version. Git reflog displays all version numbers and then git reset –hard.
Episode 8: git reset –soft rolls back the version number to the staging area (less used), git checkout returns to the original state (after modifying the file), git reset HEAD index.html returns to the unstaged state. Using two together can return to the original state before committing.
Episode 10: A general understanding of the concept of branches. Bugs in online code can be fixed through branches and finally merged. Trunk master, branch branch
Episode 11: git branch View the branch git branch dev creates a branch named dev. Git checkout dev switches from master to dev branch. Development here does not affect master. git checkout master switches back to the main branch. git merge bug merges the bug branch into the main branch. Git branch –d bug deletes the bug branch. Generally speaking, if there is a conflict, the original code merge is not modified. If there is a conflict, the code must be modified manually.
Episode 12: Workflow: Development specifications: the master branch represents the online function, the dev branch is developed, and merged when mature.
Episode 13: Github is a code hosting website. Github and git have nothing to do, but they can be seamlessly connected. Register an account, create a warehouse, push local code, gitlab is a self-built tool.
Episode 14: Code hosting based on github. The rest is the same as before, use git to manage the folder, the most common commands are git remote add orgin https://github.com/wupeiqi/dbhot.git, (give the remote warehouse an alias orgin) and git push –u orgin master (or dev, branch), now GitHub has an additional command git branch -M main, which is to rename the master branch to main, and then git push -u orgin main, the effect is the same. Push the branch to git push –u origin dev. Git clone https://github.com/1.git clones the warehouse code. Although the cloned code here only displays master, it actually contains other branches. (git remote add orgin remote warehouse address has been implemented internally) and you can git checkout branches.
Episode 15: git push origin dev manually specifies to submit dev to the origin warehouse. Distributed development does not use git clone because only part of the code is updated. git pull origin dev pulls the code from the dev branch of the remote warehouse. In the company's development process: switch to the dev branch for development git checkout dev->merge the master branch to dev git merge master ->Modify the code->Submit the code git add. git commit –m 'xx' git push origin dev Return to home and continue: switch to the dev branch for development git checkout dev->Pull the code git pull origin dev->Develop->Submit Code git add . git commit –m 'xx' git push origin dev After development, go online: merge the dev branch to master for online git checkout master git merge dev git push origin master->Push the dev branch to the remote git checkout dev git merge master git push origin dev.
Episode 16: Development process at home git add . git commit –m 'at home' Git push origin dev to the company git pull origin dev needs to resolve conflicts manually. Git pull origin dev pulls the code from the code warehouse online to the local, which is equivalent to the combination of two commands (git fetch origin dev git merge origin/dev) to merge the code pulled from the version library into the workspace.
Episode 17: Rebase (rebase) makes git records simple. git rebase –i version number (optional) or git rebase –i HEAD~3 merges the last three records according to the identifier before modifying the version. merge. If a version has been submitted to the remote warehouse, it is best not to merge it.
Episode 18: The second application scenario of git rebase git log --graph --pretty=format: "%h %s"
Episode 19: The third application scenario of git rebase at home and in the company, not used git pull uses git fetch origin dev, and git rebase origin/dev will not cause forks during the merge process. Git rebase creates conflicts, resolve them later with git rebase –continue,
Episode 20: Quickly resolve conflicts with beyond compare software. Git config –loacl merge.tool bc3 git config –local mergetoolpath ‘/user/local/bin/bcomp’ git config –local mergetool.keepBackup false Apply beyond compare to resolve conflicts git mergetool Chapter 21: Add
remote connection (alias) git remote add orgin address pushes code git push origin dev downloads code git clone address pulls code git pull origin dev is equivalent to git fetch origin dev git merge origin/dev keeps code submission clean (git rebase branch) records graphic display git log – graph –pretty=format:”%h %s”
Episode 23: gitflow is to switch between each dev and release version before release. The first way to create a warehouse is on the github website manually and invite collaborators. The second way is to use the organization form in github (you need to pay to create an organization)
Git tag –a v1 –m “first version” git push origin –tags to tag the online version
Episode 24: Multi-person collaborative development To invite members. Git checkout –b dev (equal to git branch dev creates dev branch git checkout dev)
Episode 25: Uh. . These operations are all processes of large companies. . Individual developers and small companies don’t use it very much. Let’s get a general idea first.
Episode 26: Some operational configurations for pre-submission review.
Episode 27: git branch git checkout –b release git push origin release.
Episode 28: Contribute code to open source projects. I like django and I know python quite well. This section is a bit interesting. Take tornado as an example. 1. Fork the source code. Just click fork in the upper right corner. After clicking, Copy other people's source code to your own remote warehouse 2. Make modifications in your own warehouse cd mygithub/->git clone https://github:com/cmfsz/tornado.git ->cd tornado/->Modify the code- >git add .->git commit –m 'Modify a fatal bug'->git push origin master3. Submit an application to fix the bug (pull request) to the source code author and click new pull request, create pull in your tornado warehouse request
Episode 29: Configuration files are stored in three locations. Git config –system user.name 'wupeiqi', the first configuration file project configuration file.git/config configures it. git config –local only takes effect for the current project. The second configuration file global configuration file current user home file/.gitconfig git config –global is effective for all git projects. The third configuration file system configuration file: /etc/.gitconfig git config –system (requires root permission) Chapter
30 Set: Password-free login, reflected in 1. URL, original address: https://github.com/wupeiqi/dbhot.git modified address: https://username:[email protected]/wupeiqi/dbhot. git
Git remote add origin https://username:[email protected]/wupeiqi/dbhot.git
Git push origin master
2. SSH implementation generates public and private keys ssh-keygen exists by default ~/.ssh (current user root Directory home) id_rsa.pub public key, id_rsa private key -> copy the contents of the public key and set it to github -> configure the ssh address in git local git remote add origin [email protected]:lz/dbhot.git -> You no longer need to enter your username and password in the future. git push origin master
3. git automatically manages credentials.
Episode 31: gitignore ignores files: This file must be generated using the git touch command. You can directly write the file name in .gitignore to ignore the file. You can use wildcards such as
.text, you can even use .gitignore, the folder writing method files/ ignores all files in the file folder, .h,!ah ignores all .h files except ah. .py[c|a|b] excludes pyc, pyb, and pya suffix files. For details, please see the information in the gitignore github repository.
Episode 32: Issues related to task management: You can ask questions in the issues in github. The documentation and task management wiki recommend that each project's wiki should write an introduction to the project. Episode 33:
nullundefinenull.

Guess you like

Origin blog.csdn.net/returnadsss/article/details/130298762