gpt4 book ai didi

Git 相当于 Mercurial 阶段?

转载 作者:行者123 更新时间:2023-12-02 19:48:23 26 4
gpt4 key购买 nike

在 Mercurial 中,我经常使用 secret 变更集来跟踪我对尚未准备好推送的内容的工作。然后,如果我需要对某些文件进行紧急更改,我可以更新到公共(public)修订版,进行更改并推送它,而不必担心我未完成的变更集被推送。

IE:

hg commit -sm "Partial work"
# Crap, prod is down
hg up -r <public version number>
hg commit -m "Fixin prod"
hg out
1 outgoing change, "Fixin prod"
hg push
hg rebase -r <secret revisions> -d.
# later
hg commit --amend -m "Finished work"
hg phase -dr.
hg out
1 outgoing change, "Finished work"
hg push

你会如何在 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 stash :

# ... work on new feature ...
# oh noes, production caught a killer virus from aliens
$ git stash
# ... fix and commit and push ...
$ git stash apply # reapply your stashed code
# resume hacking on your new feature.

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

关于Git 相当于 Mercurial 阶段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31751228/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com