1. Configure global accounts
git config --global user.name git config —global user.email git config -l View all configurations
2. Get the remote code (xxx is the remote branch)
git remote add origin xxx git clone xxx tips: a.Create a version library if you create your own new project git init b.If some hidden files are not visible in command line mode, use ls -ah (View hidden files) c.View Remote Sources git remote -v/version d.Delete remote sources git remote remove/rm [Name] d.Modify remote sources git remote set-url origin [Name]
3. Build new branches and develop them locally
git branch dev(Create branches) git checkout dev (Switching branch) git checkout -b dev (Create and switch branches) git branch -d dev(Delete local branches) git branch -d -r dev git branch -a (View remote branches) git branch --set-upstream-to=origin/dev Modify the corresponding branch git branch --set-upstream master origin/next git branch -vv View the correspondence between local and remote branches git branch -b dev(Create and switch branches) git branch (You can view local branching*It's the branch you're currently revising.
4. If you need to pull the remote update code in the development process, you need to submit the current development branch to the local and pull the remote branch code first.
git status (Look at all the files for this modification) git diff xxx(If some files are modified to see how they compare with the last submission, you can use diff) git add --all(Add all files for this modification) git commit -m"Notes"(Submit this modification to local area) git merge origin/master(Pull remote master Code and merge it into the current development branch) git fetch -p Delete local remote modification branches git pull => git fetch + git merge git pull --rebase =>git fetch + git rebase
5. The development needs to be pushed to remote
git add --all(Add all files for this modification) git commit -m"Notes"(Submit this modification to local area) git push important: Push code to remote branch a.[Push to local branch to remote branch) git push <Remote host name> <Local Branch Name>:<Remote Branch Name> eg: git push origin dev:master b.[If remote branches are ignored, they are pushed to exist with local branches.'Tracking relationship'If the remote branch does not exist, it will be created. git push <Remote host name> <Local Branch Name> eg: git push origin dev c.[If the local branch is ignored, an empty branch is pushed to the remote, and the remote branch is deleted.) git push <Remote host name> <Remote Branch Name> eg: git push origin :master Equate to git push origin --delete master d.[Current local branch and remote branch have traceability relationship. Local branch and remote branch can be ignored, which is equivalent to pushing the current branch to the corresponding branch of the host. git push <Remote hostname> eg: git push origin e.[If the current branch has only one tracking branch, the host name can be ignored.) git push f.[When configuring multiple trace relationships between the current branch and the remote host, you can use-u Specify default hosts] git push -u origin master(It can be used directly afterwards. git push Submission) e.Push all local branches git push --all origin f.In case of conflict, compulsory coverage git push --force origin
6. The project is restarted and the corresponding branch code needs to be retrieved
git pull <Remote host name> <Remote Branch Name>:<Local Branch Name>
Other commonly used:
git status View submission status git log /git reflog View submission records