简体   繁体   English

git命令为hg命令

[英]git commands as hg commands

I had worked with Mercurial but now working with Git. 我曾与Mercurial合作,但现在与Git合作。 I have some difficulty with understanding Git, can you help me, what are the alternatives to Git commands like Mercurial: 我对理解Git有些困难,你能帮帮我吗,像Mercurial这样的Git命令有哪些替代方法:

hg up -C 
hg revert --all 
hg purge

If I have some conflicts from the Mercurial command " hg up ", I can run commands like hg revert --all & hg purge or hg up -C . 如果我从Mercurial命令“ hg up ”中遇到一些冲突,我可以运行hg revert --all & hg purgehg up -C

What can I do after git pull and file conflicts if I don't want to continue, but just revert to the original state, or update files without conflicts (like hg up -C )? 如果我不想继续,只是恢复到原始状态,或者更新没有冲突的文件(比如hg up -C ),我可以在git pull和文件冲突后做什么?

What can I do after "git pull" and file's conflicts, if I don't want to continue, but just revert to the original state 如果我不想继续,只是恢复到原始状态,我可以在“git pull”和文件冲突之后做些什么

When you do a git pull , you are really doing a git fetch followed by either a git merge or a git rebase . 当你执行git pull ,你实际上正在进行git fetch然后是git merge git rebase Assuming your pull strategy is using merge, then your question is how can you undo the merge done during a git pull . 假设您的拉策略是使用合并,那么您的问题是如何在git pull期间撤消合并。 One clean way to undo a merge is to reset your local branch to the latest commit: 撤消合并的一种简洁方法是将本地分支重置为最新提交:

git reset --hard <SHA-1 hash of latest commit>

What can I do ... update files without conflicts (like hg up -C) 我该怎么做...更新文件没有冲突(如hg up -C)

When you do a git pull , you bring in the changes to all the files from the remote branch. 当您执行git pull ,您将对远程分支中的所有文件进行更改。 Usually you would not want to update only files which have no conflicts. 通常,您不希望仅更新没有冲突的文件。 Git is a workspace -based version control system, as opposed to something like SVN, which is a file -based VCS. Git是一个基于工作空间的版本控制系统,而不像SVN,它是一个基于文件的VCS。

If you really want to try doing a git pull and then update only files which are not in conflict, then you can use the following command to identify which files have conflicts: 如果你真的想尝试执行git pull然后只更新没有冲突的文件,那么你可以使用以下命令来识别哪些文件有冲突:

git diff --name-only --diff-filter=U

Then for each file in the list, you can do a git reset on it: 然后对于列表中的每个文件,您可以对其执行git reset

git checkout -- filename_in_conflict

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM