First, the basic action
The branch in Git is actually just a checksum containing the object (40 character length SHA-1 string)
files, so creating and destroying a branch becomes very inexpensive.
How does Git know what branch you are currently working on? In fact, the answer is also very simple, it holds a
A special pointer called head.
Create: Git branch iss53
Delete: Git branch-d iss53
Toggle: Git Checkout iss53
Create and toggle: Git checkout-b iss53
To see which branches have been m
policy:First of all, the master branch should be very stable, that is, only to release the new version, usually do not work on it. Work is 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 version 1.0 on Master. Everyone has their own branch, and sometimes it's time to merge on the Dev branch.Merging branches, plus the--NO-FF parameter can be combined with normal mode, the merged history has branches,
a remote push Send all local tags for push to remote delete remote label store current workspace State view stored workspace State Restore specified stash delete stash restore and remove the specified stash associate a local repository with a remote repository clone project from a remote repository cloning item cannot be first in the local Init version library S
branches: git checkout-b Merge a branch to the current branch: git merge Delete branch: Git branch-d -------Resolve Conflicts-------$ git log--graph--pretty=oneline--abbrev-commit Branch Merge diagram ----------Branch management policy?----------Master Branch Master The cleanest branch does no action on this branchDevelop Branch Dev Developer's main work branch, used for cycle development, rapid iterative developmentModify a bug Fixbug a branch of a bug??????????????????? A very important chap
as to publish, Or, if the dev branch code is stable, it can be merged into Master Branch master.Seven: Bug branches:In the development, will often encounter bug problems, then there is a bug need to fix, in Git, the branch is very powerful, each bug can be repaired by a temporary branch, after the completion of the repair, merge branches, and then delete the temporary branch.For example, when I get a 404 bug in development, we can create a 404 branch to fix it, but the work on the current dev b
to fix, in Git, the branch is very powerful, each bug can be repaired by a temporary branch, after the completion of the repair, merge branches, and then delete the temporary branch.For example, when I get a 404 bug in development, we can create a 404 branch to fix it, but the work on the current dev branch is not yet committed. such as the following:It's not that I don't want to commit, but the work is done halfway through, and we're not able to commit it, such as my branch Bug, which takes 2
branches:In the development, will often encounter bug problems, then there is a bug need to fix, in Git, the branch is very powerful, each bug can be repaired by a temporary branch, after the completion of the repair, merge branches, and then delete the temporary branch.For example, when I get a 404 bug in development, we can create a 404 branch to fix it, but the work on the current dev branch is not yet committed. such as the following:It's not that I don't want to commit, but the work is don
provides a stash feature that can "hide" the current work site, and then continue to work after resuming the site later. As follows:So now I can fix the bug by creating a issue-404 branch.First we want to make sure that the bug is fixed on that branch, for example, I'm now fixing it on the master Branch master, and now I'm going to create a temporary branch on the Master branch, which demonstrates the following:After the repair is complete, switch to
in general in the new Dev branch work, after the completion, such as to publish, Or, if the dev branch code is stable, it can be merged into Master Branch master.Seven: Bug branches:In the development, will often encounter bug problems, then there is a bug need to fix, in Git, the branch is very powerful, each bug can be repaired by a temporary branch, after the completion of the repair, merge branches, and then delete the temporary branch.For example, when I get a 404 bug in development, we ca
corresponding hello.txt file and find that the two lines you modified exist in the file in this form:
In this way, the content in different branches is marked and you need to manually change it and submit it with $ git add hello.txt and commit-M.
Use the $ git log with parameters to view the merging information. Take note of the parameters later.
$ git log --graph --pretty=oneline --abbrev-commit
3. Temporary Storage work site
You often encounter a situation where you are creating a new funct
DevGit add read.txtGit commit-M "Dev"Git checkout master(Note that the next parameter -- no-FF indicates that fast forward is disabled)(Fast Forward merge does not show that it has been merged, but the -- no-FF parameter merged has branches. Negative shows that it has been merged)Git merge -- no-FF-M "merge with -- no-FF" Dev(View the branch history git log -- graph -- pretty = oneline -- abbrev-commit)
Bug branch (the bugg branch is the branch to solve the bug)Idea: when there is still a job
, for example, to publish, or after the dev branch code is stable, it can be merged to the master branch.
7. Bug Branch:
During development, bugs are often encountered, so Bugs need to be fixed. In git, the branches are very powerful, and each bug can be fixed through a temporary branch, after the repair is completed, merge the branches and delete the temporary branches.
For example, when I receive a 404 bug during development, we can create a 404 branch to fix it. However, the work on the curre
completed in 1 days. However, the bug must be fixed within two hours, what should I do?Fortunately, Git also provides a stash feature that can "store" the current work site, and then continue to work after resuming the site:$ git stashNow, using GIT status to view the workspace is clean (unless you have a file that is not managed by git), so you can safely create a branch to fix the bug.First determine which branch to fix the bug on, assuming that yo
|\
| * 6224937 Add Merge
|/
* 59BC1CB Conflict fixed
...
When repairing a bug with a code name of 101, it is natural that you want to create a branch issue-101 to fix it
When fixing a bug, there is still work to be done but cannot be submitted can freeze progress
In your current workspace (branch)
$ git stash//freezes the current branch modification
See all Stash
$ git
checkout-b myfeature origin/myfeature
Save content in storage points, indexes and file systems
10. Storage
In git you can put your current working state into a storage stack and then you can take it out again. The simplest scenario is the following:
$ git Stash
# do something else ...
$ git stash pop
Many people suggest usinggit stash apply来代替pop,不过如果这样做
, and we can see that they have been merged, however, fast forward merge cannot be seen as a merger.
15. Bug Branch1. If you are currently developing on the dev branch, there is a bug that needs to be quickly resolved and merged to the master. In this case, you can create a new branch on the master (Named bug-101 ).The content on dev cannot be submitted, so you need to store it through git stash. After storing it, you can view that the work zone is c
When you update your code with GIT pull, you encounter the following problem:
Error:your local changes to the following files would is overwritten by merge: Please , commit Your changes or stash t Hem before you can merge. Aborting
This problem occurs because others have modified the xxx.php and submitted to the Repository, and you have modified the xxx.php, you have a git pull operation is a good conflict, the solution, in the above
b42294309188d57bf3398ed35660170a237d8c0aNote that the long string behind this is the SHA1 code for each commit.3. Switch to a branchgit checkout Testing4. Graphical display of branch informationGitkGITK--all5. MergeFirst, go to the branch you want to merge into, such asgit checkout MasterThe general will merge to master.and then callGit merge TestingThis will merge the changes on the testing branch.6. Delete BranchAll right, this branch, cut it out.git branch-d Testing7. Handling ConflictDuring
the last two commits, you need to run the following command.Git rebase-i head~2When you run the command, you'll see an interactive interface that lists a number of commits that let you choose which ones need to be compressed. Ideally, you choose the last commit and compress the other old commits.You will then be asked to enter the submission information for the new commit. This process essentially overrides your commit history.8.Stash UNCOMMITTED cha
in the workspace will become the non-developed Africa Zone feature before, it's so cool .Rollback is finished, small a in the thought if one day want to return to the version of the feature of the African zone what to do? Come on, you can't just look at the records and roll back through "git log" and go back to what you need to do:macbook-pro-4:p ondo jesi$ git reflog6c439d2 [email protected]{2}: Reset:moving to 6c439d2fd0d943f36f3ee84e158ff86b052961d20972f4b [Email protected]{3}: Commit: Afric
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.