利用者:Gaia.clary/Gitting
目次
- 1 Preliminaries
- 2 + Update your repository to the newest revision
- 3 + Create a branch for your specific issue
- 4 + Creating snapshots (commit)
- 5 + See the commit history of your work
- 6 + Updating your branch from the main repository
- 7 + Reverting to a previous status of your work
- 8 to be completed...
- 9 + arc patch: Get a Differential for review
- 10 + arc land: Accept a patch ...
Preliminaries
You have checked out the Blender repository and you have claimed write access to the repository. You find the basics in the Git for developers document.
I am using windows and i have created my repository at D:\blendergit\blender
this is my "working directory". Of course you will have to use your own path.
+ Update your repository to the newest revision
To ensure you have the most recent version of the blender repository you will want to update your repository as follows: cd D:\blendergit\blender
git checkout master
git pull --rebase
git submodule update --recursive --remote
First ensure that you are in your working directory (the initial cd command does just that). |
+ Create a branch for your specific issue
Lets assume you want to fix a specific Bug report, like for example the report cd D:\blendergit\blender
git checkout -b T36395
The git statement creates the branch and checks it out in one step. However you also can create a branch and check it out separately: cd D:\blendergit\blender
git branch T36395
git checkout T36395
Both approaches will create the exact same result: You have a new branch and you can go ahead with your work without "disturbing" the main branch. Hint for svn users: "checkout" does not fetch anything from the blender repository! Remind that you have a full copy of the blender repository on your computer. So the checkout fetches all data from your local disk. furthermore a checkout does only ensure that all files in your "working directory" |
+ Creating snapshots (commit)
Once in a while you may want to conserve (commit) your work results, even if your patch is not yet ready for pushing it to the blender main branch. This will allow you to revert back to a previous state of your work. For example when you messed up something then you can revert to the last snapshot easily and restart from there. You conserve your work as follows: Lets say you have changed the file cd D:\blendergit\blender\source\blender\collada
git add collada.cpp
git status
git commit -m "Fixed a call to bmesh API"
The first git command tells git that collada.cpp should be added to the next commit. Now you have saved a local snapshot of the added files. And whenever you have to revert your work, you just can go back to this snapshot (see below how this can be done) Note how this is different from Tips for working with commitSince commit is a local task you actually can commit as often as you like without affecting blender's repository. However when you finally push your work back into the repository, then all your tiny commits will be sent along... unless you take some precautions. fix a fix (Adding to the last commit)Assume you detected that your last commit contains an error and the fix would be a small change only. Now you may want to "fix the commit" instead of adding another commit. Git allows you to amend a commit as follows: git add collada.cpp
git commit -amend -m "Fixed my previous fix"
Thus you can achieve that you get only one commit containing your fix. Squash a commit chainassume you have worked on a medium sized fix or feature. Maybe you have done several commits in a line but it makes not much sense (for whichever reason) to preserve the entire commit history of your branch. Git allows you to squash all your commits together into one single "summary commit": git checkout master
git merge --squash T36395
git commit -m 'T36395: Fixed reading vertex weights.'
|
+ See the commit history of your work
You may want to scroll back in time and see some of your previous commits. actually you can jump around to any of your committed versions. But you will need to know the commit revision number to tell git where to step. For this purpose there is git log: git log
By default you will get a verbose log which displays the log messages of all commits. Each commit is reported with its commit revision number (the commit hash) in the first row. Followed by Author, Date, and the commit comment: commit 50fbebe0a443d10b3b5525c9a7e152acc32b4527
Author: Sergey Sharybin <sergey.vfx@gmail.com>
Date: Tue Nov 19 22:01:43 2013 +0600
Buildinfo fixes
- Use -M suffix if working tree does have uncommitted
modifications.
- Local commits are considered local changes as well
tricks & Tips
You can tell git to only print one line per commit: git log --oneline
Note that the commit hash is now truncated and displayed in the first column of your list. However this truncated hash is sufficient to address the related commit (see next chapter) 1ea47c9 Code Cleanup: style, spelling and pep8 edits
780459e Extra unwanted change from the previous commit
50fbebe0 Buildinfo fixes
5743a6e Code Cleanup: move trans-verts out of snap code...
035d864 Fix: tab completing a filepath name in file brow...
0c0bed3 Fix: Game Engine regression drawing text from re...
2d8d3f3 Buildbot: update configuration file
000312a Remove Surface modifier when removing force fiel...
c566e40 Cleanup: Renamed compositor executePixel functio...
3c662ef Buildbot: fix path got pack step
And you can tell git to only report the last n commits (10 in the example below): git log --oneline -n 10
|
+ Updating your branch from the main repository
While you work on your issue, other developers may have pushed their recent work to the main branch. You may occasionally (or frequently) want to add these changes to your branch as well. You want to do this to keep your working environment up to date with current development. here is what you will have to do: git checkout master;
git pull;
git rebase master T36395;
The first term will bring you back to the blender master branch. By now your branch has all recent changes applied and you can go ahead with your work. |
+ Reverting to a previous status of your work
Actually you can step to any commit that was ever made in the repository. All you need to know is the commit hash value which you can get from git checkout 50fbebe0;
Now your directory contains the status of Blender when the requested commit was ...well ...committed |
to be completed...
moving your work into the main branch
Pushing your work to the Blender repository
when something goes wrong (resolving conflicts)
+ arc patch: Get a Differential for review
git checkout master
git pull --rebase
arc patch Dxxx;
The arc command will create a new branch |
+ arc land: Accept a patch ...
After you have tested a branch that was created with arc patch, you can accept the patch and push it to the master branch in one step: arc land
However, sometimes Landing current branch 'arcpatch-Dxxx'.
Switched to branch master. Updating branch...
The following commit(s) will be landed:
a0a1f2e Fix for Txxxxx
Switched to branch arcpatch-Dxxx. Identifying and merging...
Usage Exception: arc can not identify which revision exists
on branch 'arcpatch-Dxxx'. Update the revision with recent
changes to synchronize the branch name and hashes,
or use 'arc amend' to amend the commit message at HEAD,
or use '--revision <id>' to select a revision explicitly.
Here is a workaround for this situation: git branch master
git pull --rebase
git branch arcpatch-Dxxx
arc land --hold --revision Dxxx
git push
actually you only need the last 2 commands. The first 3 commands are just to be sure you commit on the most recent version of master |