$ git diff (1)$ git diff--cached (2)$ git diff HEAD (3)git differ # # S and W ratio togit diff--staged # # S and H comparisongit diff HEAD # # W and H comparisongit diff--stat HEAD # dittoUndo Error:git reset file1 # # recover from H to Sgit checkout file1 # # recover from S to Wgit checkout HEAD # # recover from H to WRemove and rename:git rm file1 # removed from W and S, deleted from H when committedgit rm--cached file1 #从 S Deletegit mv file1 file2 # renamed from W and S, commit takes effectg
Git Proxy: Set up proxygit config--global http.proxy proxy addressRepository Clonegit clone git addressgit checkout BranchnameWork Flow:1. Create a new branch for a feature on it, preferably on a remote repository-create locally to choose which branch to base on 2.add These changes to stage-- Select in Sourcetree to add files directly to the stage 3. temporarily modify git stash 4. switch back to the main branch update code git checkout devel
/refs/tags/old_practiceAfter you take a photo, you can execute the git describe command to display the latest commit as an easy-to-remember name.The most recent milestone from the submission is selected as the "base version number", followed by the identity distance "base version"and an abbreviation for the SHA1 hash value of the commit. Because the latest submission was hit by a "milestone".So the name of the milestone is displayed directly. This technique is often used in the following example
whatchanged # show file changes for commit history the git revert dfb02e6e4f2f7b573337763e5c0013802e392818 # Undo Commit dfb02e6e4f2f7b573337763e5c0013802e392818 -Git ls-Tree HEAD # internal command: Show a Git object inGit rev-parse v2.0# Internal command: Displays a ref for the SHA1 HASH the git Reflog # shows all commits, including orphaned nodes thegit show [email protected]{5} About git show [email protected]{yesterday} # shows the status of the Master branch yesterday thegit log--pretty=f
information for each branchgit br--merged # View branches that have been merged into the current branchgit br--no-merged # View branches that have not been merged into the current branchGit Co Git co-b git co-b Git Co $id # Checkout A history commit record, but without branching information, switching to another branch will automatically deleteGit co $id-B git br-d git br-d Branch Merging and Rebasegit merge git merge origin/master--no-ff # do not fast-foward merge so you can generate a merge c
Remote Branchgit br Git br-v # View the last commit information for each branchgit br--merged # View branches that have been merged into the current branchgit br--no-merged # View branches that have not been merged into the current branchGit Co Git co-b git co-b Git Co $id # Checkout A history commit record, but without branching information, switching to another branch will automatically deleteGit co $id-B git br-d git br-d Branch Merging and Rebasegit merge git merge origin/master--no-ff # do
Suppose you are currently working on the Dev branch, but you need to fix the bug right away, how do you handle it?Since the work of Dev is not yet completed, it cannot be submitted,1, use the git stash command to save the current job site, and so on after the recovery site to continue to work.Git stash2, assuming the bug is on the master branch, create a temporary branch from mastergit checkout MasterGit checkout-b issue-1013, modify the bug, then add
Library
Git checkout-B devCreate a dev branch and switch to the dev branch.
Git branchView all current branches
Git checkout masterSwitch back to master Branch
Git merge devMerge dev branches on the current Branch
Git branch-d devDelete dev Branch
Git branch nameCreate Branch
Git stashHide the current job and resume the job after the job is resumed.
Git stash listView the list of all hidden files
Git stash
to partition 2. View the branch that is currently pointing:git branch lists all the branches, and the branch that is currently pointing to has more than one * 3, switch branch is git checkout branchname 4. Merge branch:git merge branchname merge branchname to current branch 5. Delete branch:git branch-d branchname delete branchname BranchNote: creating, merging, and deleting branches is fast, andgit encourages the use of branching to accomplish a task, deleting the branch after merging, and
resolution (Updated upstream and = = between the content is pull down, if you do not need to delete, you can delete the local line)Git stash (staging local content)Git pullgit stash pop stash@{0}{stash@{0} modify the tag to restore the staging content}Delete Branch (provided that the branch being deleted is not the cu
TIG instead of diff and Log,brew install TIG on your MacGit Local Branch ManagementView, toggle, create, and delete branchesGit br-r # View Remote Branchgit br Git br-v # View the last commit information for each branchgit br--merged # View branches that have been merged into the current branchgit br--no-merged # View branches that have not been merged into the current branchGit Co Git co-b git co-b Git Co $id # Checkout A history commit record, but without branching information, switching to a
occurs during git pull, you can
Git stash
Git pull
Git stash pop
To solve the problem, cache the local code through stash, then download the remote code from git pull, and then git stash pop. In this way, conflicting files will be merged and some conflicts need to be resolved manually. And then gitAdd
Git commit ..
Gi
# View Remote Branchgit br Git br-v # View the last commit information for each branchgit br--merged # View branches that have been merged into the current branchgit br--no-merged # View branches that have not been merged into the current branchGit Co Git co-b git co-b Git Co $id # Checkout A history commit record, but without branching information, switching to another branch will automatically deleteGit co $id-B git br-d git br-d Branch Merging and Rebasegit merge git merge origin/master--no-
information for each branchgit br--merged # View branches that have been merged into the current branchgit br--no-merged # View branches that have not been merged into the current branchGit Co Git co-b git co-b Git Co $id # Checkout A history commit record, but without branching information, switching to another branch will automatically deleteGit co $id-B git br-d git br-d Branch Merging and Rebasegit merge git merge origin/master--no-ff # do not fast-foward merge so you can generate a merge c
README2 # Rename file Readme to README2 git reset--hard Head # Resets the current version to head (typically used for merge failure fallback) git rebasegit branch-d hotfixes/bj VEP933 # Delete Branch hotfixes/bjvep933 (this branch modification has been merged into another branch) git branch-d hotfixes/bjvep933 # force Delete Branch Hotfixes/bjvep933git ls-files # list git index contains files git show-branc H # Diagram Current branch history git show-branch--all # diag
# View Remote Branchgit br Git br-v # View the last commit information for each branchgit br--merged # View branches that have been merged into the current branchgit br--no-merged # View branches that have not been merged into the current branchGit Co Git co-b git co-b Git Co $id # Checkout A history commit record, but without branching information, switching to another branch will automatically deleteGit co $id-B git br-d git br-d Branch Merging and Rebasegit merge git merge origin/master--no-
last commit information for each branchgit br--merged # View branches that have been merged into the current branchgit br--no-merged # View branches that have not been merged into the current branchGit Co Git co-b git co-b Git Co $id # Checkout A history commit record, but without branching information, switching to another branch will automatically deleteGit co $id-B git br-d git br-d Branch Merging and Rebasegit merge git merge origin/master--no-ff # do not fast-foward merge so you can genera
--cached in the current workspace to delete only the contents of the buffer zone--cached
Roll back version
--hard head/commit_id
Roll back to the future
Git reflog
Create a branch
Git branch Dev
Switch branches
git checkout Dev
Create a branch and switch branches
git checkout-b Dev
Delete Branch
git branch-d Dev
Submit a new version on a branch
' Dev1 '
Merging branches
git merge Dev
# View branches that have not been merged into the current branch git Co# Switch to a branch git cob # Create a new branch and switch past Git cob # Create new New_branchgit Co $id based on Branch # Checkout a history commit record, but without branching information, switching to another branch will automatically delete the Git co $idb # Make A history commit record checkout out, create a branch git br-D # Delete a branch git br-D # Force a branch to be removed (a branch that has not been merge
the last commit information for each branchgit br--merged # View branches that have been merged into the current branchgit br--no-merged # View branches that have not been merged into the current branchGit Co Git co-b git co-b Git Co $id # Checkout A history commit record, but without branching information, switching to another branch will automatically deleteGit co $id-B git br-d git br-d Branch Merging and Rebasegit merge git merge origin/master--no-ff # do not fast-foward merge so you can ge
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.