- 浏览: 793379 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (651)
- Java (39)
- Java 初学者小问题 (66)
- 设计模式 (7)
- 项目管理 (3)
- 数据库 (1)
- 算法 (2)
- Java practices (6)
- Effective Java2读书笔记 (78)
- Linux (2)
- programming ruby 读书笔记 (5)
- Core Java Ninth Edition Volume I 读书笔记 (15)
- Pro Git 读书笔记 (12)
- Git (3)
- Maven in Action 读书笔记 (20)
- Web (12)
- 非技术类书籍 (11)
- 电影 (40)
- Web Cache (1)
- jquery (0)
- 历史 (4)
- Dive Into HTML5 读书笔记 (13)
- 三国演义小学毕业考 (79)
- 高效能人士的7个习惯 读书笔记 (12)
- Java Performance 读书笔记 (3)
- Protocol Buffer 学习笔记 (6)
- Mongo DB 学习笔记 (7)
- Morphia 学习笔记 (7)
- Algorithms -- Princeton 学习笔记 (13)
- String研究 (10)
- Hadoop: The Definitive Guide 读书笔记 (3)
- Java与模式读书笔记 (5)
- Date研究 (3)
- The Roman Empire 听课笔记 (4)
- Algorithms -- Standford 学习笔记 (16)
- Core Java Ninth Edition Volume II 读书笔记 (9)
- Thinking in Java 4th Edition 读书笔记 (21)
- Node : Up and Running 学习笔记 (5)
- Eloquent Javascript (8)
- Smashing Node.js 读书笔记 (1)
- Algorithms II -- Standford 学习笔记 (19)
- Algorithm II -- Princeton 学习笔记 (14)
- 网络安全 (2)
- Javascript (4)
- 正则表达式 (1)
- JAVA 7/8 (15)
- JVM (10)
- NodeJS (1)
- 鸟哥的linux私房菜读书笔记 (14)
- Web Service (1)
- The art of programming (9)
- Introduction to Algorithm 读书笔记 (4)
- Java 源码阅读 (0)
- Spring in Action 读书笔记 (2)
- Java Network Programming 读书笔记 (2)
最新评论
-
心存高远:
谢谢作者分享,刚好看到这里不太明白,现在茅塞顿开。不过runt ...
关于 Maven的传递依赖的理解 -
sxlkk:
851228082 写道甚至在某次技术会议现场遇到《Maven ...
关于 Maven的传递依赖的理解 -
851228082:
851228082 写道a----compile----b-- ...
第五章 坐标和依赖 -
851228082:
a----compile----b-----provided- ...
第五章 坐标和依赖 -
851228082:
甚至在某次技术会议现场遇到《Maven in action》的 ...
关于 Maven的传递依赖的理解
1. Branching means you diverge from the main line of development and continue to do work without messing with that main line.
2. When you commit in Git, Git stores a commit object that contains a pointer to the snapshot of the content you staged, the author and message metadata, and zero or more pointers to the commit or commits that were the direct parents of this commit: zero parents for the first commit, one parent for a normal commit, and multiple parents for a commit that results from a merge of two or more branches.
3. Staging the files checksums each one (the SHA-1), stores that version of the file in the Git repository (Git refers to them as blobs ), and adds that checksum to the staging area. When you create the commit, Git checksums each subdirectory and stores those tree objects in the Git repository. Git then creates a commit object that has the metadata and a pointer to the root project tree so it can re-create that snapshot when needed.
4. If you make some changes and commit again, the next commit stores a pointer to the commit that came immediately before it.
5. A branch in Git is simply a lightweight movable pointer to one of these commits. The default branch name in Git is master . As you initially make commits, you're given a master branch that points to the last commit you made. Every time you commit, it moves forward automatically.
6. git branch [branch-name] command creates a new pointer at the same commit you're currently on.
7. Git keeps a special pointer called HEAD which is a pointer to the local branch you're currently on.
8. To switch to an existing branch, you run the git checkout command:
$ git checkout testing
This moves HEAD to point to the testing branch:
What is the significance of that? Well, do another commit and you will see:
9. git checkout command did two things: it moved the HEAD pointer back to point to the target branch, and it reverted the files in your working directory back to the snapshot that the target branch points to. Note that if your working directory or staging area has uncommitted changes that conflict with the branch you're checking out, Git won't let you switch branches.
10. A branch in Git is in actuality a simple file that contains the 40-character SHA-1 checksum of the commit it points to, branches are cheap to create and destroy. Developers are encouraged to create and use branches often.
11. To create a branch and switch to it at the same time, you can run the git checkout command with the -b switch:
$ git checkout -b iss53
12. If you want to merge hotfix branch back into your master branch, you can do this:
$ git checkout master
$ git merge hotfix
13. When you try to merge one commit with a commit that can be reached by following the first commit's history, Git simplifies things by moving the pointer forward because there is no divergent work to merge together—this is called a fast forward.
14. To delete a branch, you can delete it with the -d option to git branch :
$ git branch -d hotfix
15. If the commit on the branch you're on isn't a direct ancestor of the branch you're merging in, Git has to do some work. In this case, Git does a simple three-way merge, using the two snapshots pointed to by the branch tips and the common ancestor of the two.
Git creates a new snapshot that results from this three-way merge and automatically creates a new commit that points to it. This is referred to as a merge commit and is special in that it has more than one parent.
16. If you changed the same part of the same file differently in the two branches you're merging together, Git won’t automatically created a new merge commit. It has paused the process while you resolve the conflict. To see which files are unmerged at any point after a merge conflict, you can run git status . Git adds standard conflict-resolution markers to the files that have conflicts, so you can open them manually and resolve those conflicts.
17. Your conflict file contains a section that looks something like this:
<<<<<<< HEAD:index.html
<div id="footer">contact : email.support@github.com</div>
=======
<div id="footer">
please contact us at support@github.com
</div>
>>>>>>> iss53: index, html
This means the version in HEAD is the top part of that block (everything above the ======= ), whereas the version in your iss53 branch looks like everything in the bottom part.
18. After you've resolved each of these sections in each conflicted file, run git add on each file to mark it as resolved. Staging the file marks it as resolved in Git.
19. To use a graphical tool to resolve these issues, you can run git mergetool . You will see all the supported tools listed at the top after "merge tool candidates ". Type the name of the tool you'd rather use. After you exit the merge tool, Git asks you if the merge was successful. If you tell the script that it was, it stages the file to mark it as resolved for you. After you verify that everything that had conflicts has been staged, you can type git commit to finalize the merge commit.
20. I f you run git branch with no arguments, you get a simple listing of your current branches. The * character that prefixes the branch indicates the branch that you currently have checked out. To see the last commit on each branch, you can run git branch –v .
21. To see which branches are already merged into the branch you're on, you can run git branch –merged . To see all the branches that contain work you haven't yet merged in, you can run git branch --no-merged . Because it contains work that isn't merged in yet, trying to delete it with git branch -d will fail, however you can force it with –D .
22. Many Git developers have a workflow that embraces this approach, such as having only code that is entirely stable in their master branch—possibly only code that has been or will be released. They have another parallel branch named develop or next that they work from or use to test stability—it isn't necessarily always stable, but whenever it gets to a stable state, it can be merged into master . It's used to pull in topic branches (short-lived branches for hox-fix and new feature) when they're ready, to make sure they pass all the tests and don't introduce bugs.
23. Remote branches are references to the state of branches on your remote repositories. They're local branches that you can't move; they're moved automatically whenever you do any network communication. Remote branches act as bookmarks to remind you where the branches on your remote repositories were the last time you connected to them. They take the form (remote)/(branch) : origin/master
24. If you clone from a remote git repoitory, Git automatically names it origin for you, pulls down all its data, creates a pointer to where its master branch is, and names it origin/master locally; and you can't move it. Git also gives you your own master branch starting at the same place as origin's master branch:
25. When you run a git fetch origin command. This command looks up which server origin is, fetches any data from it that you don't yet have, and updates your local database, moving your origin/master pointer to its new, more up-to-date position:
26. If you have a branch named serverfix that you want to work on with others, you can push it up the same way you pushed your first branch. Run:
Git push origin serverfix
27. This is a bit of a shortcut. Git automatically expands the serverfix branch name out to refs/heads/serverfix:refs/heads/serverfix , which means, "Take my serverfix local branch and push it to update the remote's serverfix branch." You can also do git push origin serverfix:awesomebranch if you don't want it to be called serverfix on the remote. When you do a fetch that brings down new remote branches, you don't automatically have local, editable copies of them. If you want your own serverfix branch that you can work on, you can base it off your remote branch:
$ git checkout -b serverfix origin/serverfix
This gives you a local branch that you can work on that starts where origin/serverfix is.
28. Checking out a local branch from a remote branch automatically creates what is called a tracking branch. Tracking branches are local branches that have a direct relationship to a remote branch. If you're on a tracking branch and type git push , Git automatically knows which server and branch to push to. Also, running git pull while on one of these branches fetches all the remote references and then automatically merges in the corresponding remote branch.
29. When you clone a repository, it generally automatically creates a master branch that tracks origin/master . That's why git push and git pull work out of the box with no other arguments.
30. You can set up other tracking branches if you wish—ones that don't track branches on origin and don't track the master branch by:
git checkout -b [ branch] [ remotename]/[ branch]
You can also use --track shorthand for Git version 1.6.2 or later:
$ git checkout --track origin/serverfix
31. You can delete a remote branch using the rather obtuse syntax:
$ git push [remotename] :[branch]
A way to remember this command is by recalling the git push [remotename] [localbranch]:[remotebranch] syntax. If you leave off the [localbranch] portion, then you're basically saying, "Take nothing on my side and make it be [remotebranch] ."
32. In Git, there are two main ways to integrate changes from one branch into another: the merge and the rebase .
33. With the rebase command, you can take all the changes that were committed on one branch and replay them on another one.
Before rebase:
Then you run:
$ git checkout experiment
$ git rebase master
After rebase:
At this point, you can go back to the master branch and do a fast-forward merge.
34. rebase works by going to the common ancestor of the two branches (the one you're on and the one you're rebasing onto), getting the diff introduced by each commit of the branch you're on, saving those diffs to temporary files, resetting the current branch to the same commit as the branch you are rebasing onto, and finally applying each change in turn.
35. The snapshot pointed to by the final commit you end up with, whether it's the last of the rebased commits for a rebase or the final merge commit after a merge, is the same snapshot—it's the history that is different. Rebasing replays changes from one line of work onto another in the order they were introduced, whereas merging takes the endpoints and merges them together, but rebasing makes for a cleaner history. If you examine the log of a rebased branch, it looks like a linear history: it appears that all the work happened in series, even when it originally happened in parallel.
36. If you have following branches:
You can take the changes on client that aren't on server (C8 and C9) and replay them on your master branch by using the --onto option of git rebase:
$ git rebase --onto master server client
This basically says, "Check out the client branch, figure out the patches from the common ancestor of the client and server branches, and then replay them onto master .":
You can rebase the server branch onto the master branch without having to check it out first by running git rebase [basebranch] [topicbranch] —which checks out the topic branch (server ) for you and replays it onto the base branch (master ).
37. Do not rebase commits that you have pushed to a public repository. When you rebase stuff, you're abandoning existing commits and creating new ones that are similar but different. If you push commits somewhere and others pull them down and base work on them, and then you rewrite those commits with git rebase and push them up again, your collaborators will have to re-merge their work and things will get messy when you try to pull their work back into yours.
发表评论
-
授权申明
2012-04-13 18:40 846近日我将我在iteye上发布的《Pro Git读书笔记》做成电 ... -
《Pro Git》读后感
2012-03-18 18:26 2330开始接触Git是在去年年初,公司开始从Clearcase 过度 ... -
Chapter 9. Git Internals
2012-03-18 17:27 24321. Git is fundamentally ... -
Chapter 8. Git and Other Systems
2012-03-17 21:44 13091. git svn allows y ... -
Chapter 7. Customizing Git
2012-03-17 16:10 18391. Git uses a series of ... -
Chapter 6. Git Tools
2012-03-13 19:52 13591. Git is smart ... -
Chapter 5. Distributed Git
2012-03-05 23:10 16621. You can easil ... -
Chapter 4. Git on the Server
2012-03-03 16:23 19531. The preferred method ... -
Chapter 2. Git Basics
2012-02-27 21:17 15781. You can get a ... -
Chapter 1. Getting Started
2012-02-26 15:31 32631. Version control is a system ... -
《Pro Git》
2011-11-27 21:43 926A very good git tutorial: ...
相关推荐
问题描述: 在使用git 进行提交时, 出现上面这个报错, 导致无法提交. 报错大致意思就是创建index.lock文件失败,因为已经存在index.lock文件了. index.lock文件是在.git下面, 而.git是一般是隐藏的, 那么可以通过以下...
3. 安全更新:关注Bonobo.Git.Server的更新,及时打补丁以修复潜在的安全漏洞。 总结,Bonobo.Git.Server为小型团队提供了便捷的本地Git服务器解决方案,它的直观界面和灵活配置使得Git的使用门槛降低,提升了开发...
Windows系统条件下,批量清除git版本管理配置文件,批量删除.git文件夹 使用方法:下载将该脚本文件,拷贝到要清除的项目的文件夹目录下,双击bat文件即可。
今天Git push的时候 fatal:remote error: You can't push to git://github.com/username/*.git Use git@github.com:username/*.git 看来我是没有权限push啊。 解决方法: git remote rm origin git remote add ...
ipxe-roms-20180825-3.git133f4c.el7.noarch.rpm
torch 项目完整代码,公司无法使用git,所以放了个备份在csdn上 (git clone https://github.com/torch/distro.git ~/torch --recursive)
aix7.2系统下安装git客户端
3. **恢复文件**:通过解析`.git`数据,GitHack能恢复被删除或修改的文件。 4. **分析敏感信息**:工具可能会检查配置文件、密码哈希等可能暴露的敏感信息。 在CTF比赛中,利用GitHack可以实现以下目标: - **信息...
find . -name '.git' | sed -e 's/^/rm -rf /g'| /bin/sh
在Mac上显示隐藏的.git文件夹,可以通过终端使用命令行操作。打开终端,输入以下命令使隐藏的文件和文件夹可见:mac显示隐藏的.git文件_mac 看不到.git文件夹
Learn Git in a Month of Lunches introduces the discipline of source code control using Git. Helpful for both newbies who have never used source control and busy pros, this book concentrates on the ...
git视频教程.1.Git 命令 - git help、git config.mp4 git视频教程.2.Git 命令 - git init、git clone.mp4 git视频教程.3.1.Git 命令 - git add、git status.mp4 git视频教程.3.2.Git 命令 - git diff、git difftool....
Git 自动补全.
As you progress on to the next module, you will learn how you can automate the usual Git processes by utilizing the hook system built into Git. It also covers advanced repository management, including...
将git-repo.git目录下的repo拷贝到 /usr/bin: cd git-repo.git sudo cp repo /usr/bin/repo_gitadmin 修改 repo vi /usr/bin/repo_gitadmin 修改 REPO_URL = 'https://gerrit.googlesource.com/git-repo' REPO_REV...
[Git][教學]_終端機指令#05._Git倉庫Repo版本紀錄原理與.git內容簡介
As you progress through this book, you will learn how you can automate the usual Git processes by utilizing the hook system built into Git. The book also covers advanced repository management, ...
3.Git与GitHub的简单同步1