Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 汞相的吉特当量?_Git_Version Control_Mercurial_Version Control Migration_Mercurial Phases - Fatal编程技术网

Git 汞相的吉特当量?

Git 汞相的吉特当量?,git,version-control,mercurial,version-control-migration,mercurial-phases,Git,Version Control,Mercurial,Version Control Migration,Mercurial Phases,在mercurial中,我经常使用秘密变更集来跟踪我的工作,这些变更集还没有完全准备好推进。然后,如果我需要对某个文件进行紧急更改,我可以更新到公共版本,进行更改并推送它,而不必担心未完成的更改集被推送 即: hg提交-sm“部分工作” #糟了,prod掉下来了 hg-up-r hg commit-m“Fixin prod” 冒出 1传出更改,“Fixin prod” 汞推力 hg-rebase-r-d。 #后来 hg提交——修改-m“已完成的工作” 汞相-dr。 冒出 1传出更改,“已完成工作

在mercurial中,我经常使用秘密变更集来跟踪我的工作,这些变更集还没有完全准备好推进。然后,如果我需要对某个文件进行紧急更改,我可以更新到公共版本,进行更改并推送它,而不必担心未完成的更改集被推送

即:

hg提交-sm“部分工作”
#糟了,prod掉下来了
hg-up-r
hg commit-m“Fixin prod”
冒出
1传出更改,“Fixin prod”
汞推力
hg-rebase-r-d。
#后来
hg提交——修改-m“已完成的工作”
汞相-dr。
冒出
1传出更改,“已完成工作”
汞推力
在git中如何实现这一点?

使用分支:

$ git checkout -b dev #create a new branch based on the current commit in master
# .... work ....
$ git commit -a -m 'super awesome new feature'
# oh noes, production crapped itself!
$ git checkout master
# ... fix ...
$ git commit -a -m 'fixed bug #666'
$ git push master
$ git checkout dev #since we created the branch with -b the first time, we're good now.
$ git merge master # update our dev branch with the changes in master
# ... work on new features ...
# all done and commited and tested
$ git checkout master
$ git merge dev && git branch -d dev # delete the dev branch
$ git push && profit
或者简单地使用:

我个人更喜欢分支方法,因为它更干净

在git中如何实现这一点

我从不使用默认行为“
gitpush
”。要强制执行,可以将
push.default
设置为“
nothing
”。然后有两种推送方式:

  • 设置
    remote..push
    。对于我的github内容,我通常在我的
    .git/config

    [remote "origin"]
    ...
     push = refs/heads/export/*:refs/heads/*
    
  • 因此,如果我决定某个提交已准备好进行推送,我会将分支“
    export/
    ”放在那里。在我这样做之前,提交不会被“
    gitpush
    ”推送

  • 或者总是在命令行中明确指定要推送到哪个分支。像这样:

    $git push origin 3f42873:refs/heads/12345_foo
    
  • 这就是我在工作中所做的,分支总是来来去去去,我不想跟踪它们中的每一个。不过,这会留下一些出错的机会,所以如果您想确保使用第一个选项

    此处描述了refspec语法:

    [remote "origin"]
    ...
     push = refs/heads/export/*:refs/heads/*
    
    $git push origin 3f42873:refs/heads/12345_foo