First, use Git branch to create a branchUsage Scenario: No experience at the momentGit branch-a Show All branchesGit branch xx create XX branchgit checkout xx switch to XX branchGit checkout-b xx Create and switch to XX branchSecond, use Git stash save and restore work progressUsage scenario: Develop a new feature that has not been developed yet, but need to fix a bug urgently, you can save this progress, fix the bug to commit and then resume the work
=onelineWithout using fast forward mode, the principleBranching policy:In the actual development, we should follow several basic principles of branch Management:First of all, the master branch should be very stable, that is, only to release the new version, usually do not work on it;So where do you work? Work on the Dev branch, that is, the dev branch is unstable, at some point, such as the 1.0 release, then merge the Dev branch to master and release the 1.0 version in the Master branch;You and
information is discarded after the branch is deleted, that is, the merge cannot be seen once. Adding the--NO-FF parameter can prohibit the use of Fast forward mode, the merged history has branches, can be seen to have been merged.In the actual development, the master branch should be very stable, only to release the new version, usually do not work on it;The Dev branch is unstable, and at some point, the Dev branch is merged to master;Everyone works on the dev branch, and sometimes merges on th
The specific method is as followsGit pull Origin branch // error occurred git stash // Restore git stash ClearDevelopers often encounter this situation: It took a few days to do a new function, has changed almost more than 10 files, suddenly a bug needs to be resolved urgently, and then to a build test group. It's often time-consuming and error-prone to rely on manual backups before git comes out.The git
git logGit log-p: Show the differences for each commitGit log-p-X (x number of times, integer): Specifies the number of times the variance is displayedgit log--stat: Displays a brief count of incremental row countsgit log--author= cold Jiang: Show a commit record for an authorGit checkoutGit checkout--* * (file): Revert to file modificationGit checkout-b master remotes/master: Establish a local branch to the server and switch the pastgit branch-d: Delete local BranchGit branch-d: forcibly delete
the last two lines, which will be described in the following sections. Git provides many elegant and user-friendly options. If we combine the alias settings, we can use your imagination to make your own Git live.
Color: Is it painful to watch diff every time? So why don't we add color to our Git? You only need to add the three lines to display the red and green prompts on your console.
Git agility
Now let's talk about the usage and skills of the 'git log', 'git
Transferred from: HTTPS://GITHUB.COM/KAIYE/KAIYE.GITHUB.COM/ISSUES/7After mastering the basics of Git use, you may encounter some problems. The following are some of the problems that cat Brother screening summary, share to friends, master the points in these questions, Git advanced also completed, it contains the following sections:
How to modify Origin warehouse information
How to configure Git ssh keys
How to undo Changes
How to solve the conflict
Git
git resolves local conflicts
The process is very simple, mainly using the git stash command for processing, divided into the following steps to deal with.
1. Store local Modifications first
$ git stashThis allows all local modifications to be temporarily stored. is to use Git stash list to see the saved information:
Git stash Staging changesGit
two commits modified the same line of the same file, and git does not know which one to apply. This causes the error message to resemble the following:
Git will give you 3 choices to fix the commit that caused the conflict (fa39187):
You can run git rebase--abort to completely de-base the variable. Doing so cancels the change-base modification and resets the branch back to the state it was before executing git rebase.
You can run git rebase--skip to completely ignore the commit. In this way, t
Chinese name, the following is displayed:
The stash Command uses the scene, as you are modifying the code on a branch a, but there is an urgent task that requires you to switch to another branch B to do some work, and the code on a is still a dabbler, Do not want to go to commit or even do not want to add, this time the Stash command is of great use, if no commit is executed
git
and you have not been asked to change it again until the next review. You've got some extra commits before you know it's going to change again. Ideally, you can compress multiple commits into one using the rebase command.?
1
gitrebase-iHEAD~[number_of_commits]
If you want to compress the last two commits, you need to run the following command.?
1
gitrebase-iHEAD~2
When
when useful $ git diff [file] # Compare the current file and the staging area file difference $ git diff [$id] [$id] # Compare the differences between two commits $ git diff [Branch1]. [BRANCH2] # Compare $ git diff--staged # between two branches compare staging area and repository diff $ git diff--cached # compare staging Zone and Workspace diff $ git diff--stat # Just compare statistics $ git stash # staging work currently in
working directory tree.
20. Git cleanGit clean removes files without track from the working directory. the common parameter is GIT clean-DF:-D, indicating that the directory is removed at the same time, and-F indicates force, because in the GIT configuration file, clean. requireforce = true. If-F is not added, clean will reject execution.
21. Git mvGit Rm--cached orig; MV orig new; git add new
22. Git stashPress the current change into a stack. git stash
Git end
6, at this point to view git log results found that there is only one operation record, that is, we added the a.txt of the record, we did the second step of the operation. That is, when we add the b.txt file node, how do we fall back to the last node?We can use Git reflog
7, now the demo folder in the 2 file contentsThe a.txt text reads as follows:
Initializing content
The b.txt text reads as follows:
This is B text content
We continue to add the following record information for B.txt
(reference) as a parameter to the command. git revert HEAD: Undo the most recent commit. Git revert creates a new, reverse commit that you can tell git not to commit by using parameter-N.git rmgit rm file: Removes files from the staging zone and also removes the working directory. git rm--cached: Removes files from the staging area, but stays in the working directory. git rm--cached is functionally equivalent to git reset HEAD, which clears the cache but does not move the working directory tr
master branch should be very stable, that is, only to release the new version, usually do not work on it;
So where do you work? Work on the Dev branch, that is, the dev branch is unstable, at some point, such as the 1.0 release, then merge the Dev branch to master and release the 1.0 version in the Master branch;
You and your little friends each work on the Dev branch, and everyone has their own branch, and it's time to merge on the Dev branch.
So, the branch of teamwork looks like
the submission information for the new commit. This process essentially overrides your commit history.
LweiTranslated 8 months ago1 Person topTop translation of good Oh!
8. Stash UNCOMMITTED changesYou are modifying a bug or feature and are suddenly asked to show your work. And the work you're doing is not enough to submit, and you won't be able to show it at this stage (before you go back to the change). In this case, git
line shows the merged graph,---git log--graph--pretty=oneline--abbrev-commit-An abbreviated submission ID number on one line Git stash-The main use for this branch of the reserved storage, wait until the debugging bug succeeds, then restore the original branch to continue the next workgit stash List-used to view the display of listing information for paused hold storagegit
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.