Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What commands are commonly used in git?

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains the "what commands are more commonly used in git", the content of the explanation is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "what commands are more commonly used in git"!

Git config use git config-- globa-- list / / View global variables git config-- list / / View all variables (system, global Local [if in a current repository]) git config-- global user.name "John Doe" / / configuration global variable user.name git config-- global user.email johndoe@example.com// configuration global variable user.email git config user.name// to view the value of the specified variable git config-- unset user.name// restore this setting git cofnig-- add user.addr 'xxx'// added variable git config -- get-color color.diff.whitspace "blue" / / change the display color git config-- show-origin color.diff / / the file where the display variable is located and its value git init test// initialize the test empty project WORK_TREE points to the test directory The following contains the .git (GIT_DIR) folder git init-- bare test// specifies GIT_DIR for testgit clone usage git clone http://xxx// checkout project default configuration remote master git clone-b developer http://xxx// checkout project uses the specified developer branch git clone-o book http://xxx/ to check out the project and sets the default remote name to book git clone http://xxx/ / d:test// check out the project to the specified file git clone-- bare http://xxx// checks out a naked warehouse git status usage git status / / View the status of the file Untracked (not tracked), modifiled (modify file) / / Changes not staged for commit below the line, indicating that the contents of the tracked file have changed, but have not yet been placed in the temporary storage area. To temporarily save this update to Git, you need to run the git add command. / / this is a multi-function command: you can use it to start tracking new files, or to put tracked files in a temporary storage area, and to mark conflicting files as resolved when merging. Git status-uplink / only show untracked files git status-uno// only show tracked files git diff usage git diff// view unstaged files comparison git diff-- cached// view staged files comparison git diff-- staged// view staged files comparison git commit usage git commit// submits staged files to git local warehouse Will open the editor to enter the submission prompt git commit-m 'submit prompt' / / submit the temporary file to the git local warehouse git commit-amend// re-modify the submission prompt git commit-a / / you can submit all tracked files that have been modified or deleted to the local warehouse Even if they are not added to the staging area by git add git git reset usage (head ^) git reset HEAD (default is mixed) / / reset the stage area and working directory, your HEAD and the current branch cut to the previous commit at the same time The new changes in your working directory and the new changes that have been add to the stage area are all gone. Git reset HEAD fileName// undoes git reset for a file-- head HEAD// resets the stage area and the working directory git reset-- soft HEAD//reset-- soft retains the contents of the working directory and temporary storage area when resetting HEAD and branch, and puts the new differences caused by resetting HEAD into the temporary storage area. Git reset-- mixed HEAD// retains the working directory and clears the staging area. That is, changes to the working directory, contents of the staging area, and new file differences caused by reset will be put into the working directory. In short That is, "mixed all differences in the working directory" git branch usage git branch// displays local branch information git branch-v _ vv// / shows local branch information git branch-r _ git branch / shows remote branch information git branch temp// creates branch temp git branch-d |-- delete temp// delete branch temp git branch-vv// shows that the local branch is associated with the remote branch Information git branch-- unset-upstream// cancels the relationship between the local branch and the remote branch git branch-u origin/master// local branch (HEAD) establishes a relationship with the remote branch origin/master-- set-upstream-to origin/master// local branch (HEAD) establishes a relationship with the remote branch origin/master-- list// displays all branches git branch-m temp tet// will branch Temp modified to tet git branch-D temp// forcibly delete git branch-a git branch / view all branches including local and remote git branch-c temp// create branches Have the submission information of the original branch git branch-- merged// displays the branch information that has been merged git branch-- no-merged// displays the branch information that has not been merged git checkout usage git checkout fileName// revokes the git checkout branchName// switch branch of the modified file in the workspace. Git git checkout-b branchName// create a new branch and switch = = git branch branchName + git checkout branchName git checkout. / / restore all currently modified files to the git checkout-m branchName// switch branch and merge git checkout-- datch bracnchName// switch to the free state of the branch git revert usage git revert commit_id / / revoke the specified commit git revert HEAD~3 / / cancel the last three commits git revert-n master~5..master~2// undo three commits 4,3,2 Does not include 5git remote usage git remote-v http://xxx/xx// / list all remote warehouses git remote add pb add remote warehouse git remote show pd// display remote warehouse information git remote rename pb paul// remote warehouse rename git remote rm pb// delete remote warehouse git remote set-url pb newUrl oldUrl// reset remote warehouse address git remote set-url -- add newUtl// added remote submission address git fetch usage git fetch origin// download the replacement code from the remote warehouse to the local current branch git fetch origin master:tmp / / obtain the latest from the remote warehouse master branch Set up the tmp branch git merge locally using git merge temp// to merge the branch temp code into the current branch merge command. It merges the latest snapshots of the two branches (C3 and C4) and their most recent common ancestor (C2), resulting in a new snapshot (and commit). Git merge-- ff temp// merge branches, fast forward,-- ff refers to the fast-forward command. When merging using fast-forward mode, a new commit node will not be created. By default, git-merge uses fast-forward mode git merge-no-ff temp// to merge branches, and does not use fast push. The commit history of branches is retained by git merge-squash// merges multiple branches into one using squash. At this time, the file is the same as after the merge, but the HEAD is not moved and the file is not submitted. You need to do an additional commit git merge temp master// merge branch temp and master at the top of the current branch so that they merge git merge-s ours temp// merge branches, and using the ours merge strategy git merge-- abort// will abandon the merge process and try to rebuild the pre-merge state. However, if there are files that are not commit at the beginning of the merge, / / git merge-- abort will not be able to reproduce the pre-merge state in some cases. (especially if these non-commit files will be modified during the merge) it is recommended that you use the git-stash command to temporarily store these non-commit files and use git stash pop to restore these non-commit files after the conflict has been resolved. Git merge-commit// merge successfully produces a commitgit push usage git push// defaults to commit the current branch to the remote branch git push origin master// push the local branch master to the remote origin/master If it does not exist, create a new git push pb-- delete temp// delete the remote branch git push origin: temp// delete the remote branch git push-u origin master// local branch master push to the remote master and establish an associated git push-- all origin// push all branches to the remote host does not exist, create a new remote branch git rebase usage git rebase temp// change base merge branch it The principle is to first find these two branches (that is, the current branch experiment, The nearest common ancestor C2 of the target base branch master) of the change base operation Then compare the previous submissions of the current branch relative to the ancestor, extract the corresponding changes and save them as temporary files, then point the current branch to the target base C3, and finally apply the changes previously saved as temporary files to the git rebase-abort temp// merge branch in order to restore the state before the conflict. Git rebase-continue// merge conflicts, allowing conflict resolution merge No new commitgit stash usage git stash [save] / / staging uncommitted data from the current branch / /-- keep-index option is generated. It tells Git not to store anything you have stored temporarily through the git add command. -- include-untracked or-u flag, Git will also store any created untracked files git stash list// display staging list git stash apply// will use git stash apply stash@ {2} / / specify staging recovery git stash drop stash@ {2} / delete specified staging git stash branch temp// to create a new branch from stash git cherry-pick usage (merge branches Only want to merge a commit in the branch) git cherry-pick-quit exits the current chery-pick sequence git cherry-pick-continue continues the current chery-pick sequence git cherry-pick-abort cancels the current chery-pick sequence Restore the current branch git cherry-pick-n,-- no-commit does not automatically commit git cherry-pick-e,-- edit edit submission information git cherry-pick commitid / / merge the specified submission into the current branch git rm usage (used to delete files from the workspace and index.) Git rm text.txt// deletes text.txt, disassociates git rm-r text// from git, deletes text folder, disassociates git mv usage (used to move or rename files, directories, or symbolic links) with git. (git mv text.txt text// moves text.txt to text folder thank you for your reading. The above is the content of "what commands are more commonly used in git". After the study of this article, I believe you have a deeper understanding of what commands are more commonly used in git, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report