分类目录归档:git

How to deal with the Unmerged paths

 

如果新提交的分支代码和master有冲突,先checkout到分支merge master,解决冲突,

然后再checkout master,merge 分支.

(1) git checkout edit_package_page

git merge master –no-ff

这时候会看到很多CONFLICT (add/add): Merge conflict in  <filenname>

git status 查看所有的冲突文件

vim 每一个文件解决一下冲突

git add .

git commit

git push

(2)git checkout master

git merge edit_package_pages –no-ff

git push

bitbucket新建分支

 

/workspace/ott_app_store:fetch-xml$ git branch edit_package_page
/workspace/ott_app_store:fetch-xml$ git checkout master
Switched to branch ‘master’
/workspace/ott_app_store:master$ git pull
Password for ‘https://aaa@bitbucket.org’:
Already up-to-date.
/workspace/ott_app_store:master$ git branch -a
edit_package_page
fetch-xml
* master
prepare-models
remotes/origin/fetch-xml
remotes/origin/master
remotes/origin/prepare-models
/workspace/ott_app_store:master$ git branch -d edit_package_page
error: The branch ‘edit_package_page’ is not fully merged.
If you are sure you want to delete it, run ‘git branch -D edit_package_page’.
/workspace/ott_app_store:master$ git branch -D edit_package_page
Deleted branch edit_package_page (was 3bc7673).
/workspace/ott_app_store:master$ git branch edit_package_page
/workspace/ott_app_store:master$ git checkout edit_package_page
Switched to branch ‘edit_package_page’
/workspace/ott_app_store:edit_package_page$

开始在自己的分支的基础上新建的分支,后来觉得不合适,删除新建分支,

在master的基础上又新建了分支

git参考资料

 

$git log –graph

$git reset –hard 67889898…

$ssh-add

$git pull –rebase

$git fetch (相当于pull新分支)

$git branch (查看当前所在分支)

$git checkout fetch-xml (转到fetch-xml分支)

 

参考:
  1. Pro Git http://git-scm.com/book
  2. Git Magic http://www-cs-students.stanford.edu/~blynn/gitmagic/intl/zh_cn/
  3. Git flow(A successful Git branch model) http://nvie.com/posts/a-successful-git-branching-model/
  4. Github flow http://scottchacon.com/2011/08/31/github-flow.html
  5. 构造干净的 Git 历史线索
  6. Git Cheatsheet
  1. git remote
    git remote -v
    git remove show origin 查看 origin 中所有远程分支的情况
  2. git branch
    git branch 显示所有本地分支
    git branch -a 显示所有分支
    git branch -m old_name new_name
    git branch –set-upstream <localbranch> <remotebranch>
  3. git log
    git log –pretty=oneline
    git log -n 1 显示最近的一次提交日志
    git log -n 1 –stat 显示最近一次提交更改的所有文件
    git log -n 1 –stat -p 显示最近一次提交更改的所有文件和具体的内容变更
    git log 0f9259d85875c2f078492224618abc84dbabad32 -n 1 –stat -p 显示 0f9259 提交的具体修改内容

Difference between git pull and git pull –rebase

推荐一本非常好的书 :<Pro Git>  http://iissnan.com/progit/

构造干净的 Git 历史线索  http://codecampo.com/topics/379

 

git pull = git fetch + git merge against tracking upstream branch.

git pull --rebase = git fetch + git rebase against tracking upstream branch.

 

  如果运行git pull,那么git做两件事情,首先拿到远程最新的代码,然后运行 git merge。

那么如果是git pull –rebase也是会拿到最新代码,然后运行git rebase。

接下来的问题就是git merge 和git rebase的区别了。简单来说,git merge和git rebase从最终效果来看没有任何区别,都是将不同分支的代码融合在一起,但是生成的代码树就稍微有些不同。使用git rebase,可以避免不必要的merge,使代码数保持直线,便于将来查看历史.

 

 

 

http://stackoverflow.com/questions/16666089/whats-the-difference-between-git-merge-and-git-rebase/16666418#16666418

 

git clone报错

Could not chdir to home directory /home/wangzheng: No such file or directory
fatal: ‘/gitroot/文件名’ does not appear to be a git repository
fatal: The remote end hung up unexpectedly

其实这是因为没权限导致的错误,哈哈