Programing

가장 일반적인 Mercurial 명령에 해당하는 Git?

lottogame 2020. 9. 9. 18:57
반응형

가장 일반적인 Mercurial 명령에 해당하는 Git?


Mercurial을 사용해 왔지만 Git의 간단한 데모를하고 싶습니다.

Git에 해당하는 것은 무엇입니까?

hg init . # start a project in the current directory
hg addremove # look for any added or deleted files
hg commit -m "comment" # commit any uncomitted changes
hg status # what have i changed since the last commit?

Git-HG 로제타 스톤은 나쁘지 않습니다.

거기에 언급되지 않은 두 가지 사이에 몇 가지 다른 문제가 있습니다. 이 목록은 내가 다른 길로 갔을 때 내 블로그 게시물에서 가져온 것입니다 (git-> hg).

Hg .hgignore, 구문 : glob은 git의 .gitignore와 동일한 동작입니다.

Git .git / config, ~ / .gitconfig, git-config를 사용하여
Hg .hg / hgrc, ~ / .hgrc 값 수정 , 사용hg help -c config

힘내 git commit -v
Hg hg diff | 적게; hg 커밋

Git gitk
Hg hg보기 또는 TortoiseHg의 thg

Git git gui
Hg Mercurial은 변경 세트를 선택하는 GUI를 제공하지 않고 콘솔 hg record명령 만 제공 합니다.

힘내 git rebase
Hg hg rebase . 들어 git rebase --interactive있다 HG histedit는 , 또는 의욕 대기열

Git git push URL; git remote add origin URL
Hg hg push URL; $ EDITOR .hg / hgrc; [경로] 기본값 = URL

Git gitk, git log origin / master..HEAD
Hg hg outgoing

Git git format-patch RANGE
Hg hg email -m filename -o

힘내 git add. ;
Hg hg add; 점이 필요하지 않습니다.

Git git checkout REVISION-KEY
Hg hg update CHANGESET


공백을 채우기 위해 Mercurial의 가장 유용한 명령 중 일부는 다음과 같습니다.

Hg hg 레코드
Git git add -p; 자식 커밋

Hg hg inc [URL]
Git 실제 해당 사항이 없습니다. 당신은hg pull; hg log -r .:

Hg hg out URL
Git 방법을 알고 있으면 추가하십시오.

병합 충돌 해결을 위해 hg resolveMercurial 명령에는 동작을 변경하는 몇 가지 옵션이 있습니다.

Hg hg resolve -m FILE (충돌 문제를 수동으로 수정하여 파일이 해결 된 것으로 표시)
Git git add FILE

Hg hg resolve -u FILE 는 파일을 해결되지 않은
Git git reset HEAD FILE 으로 표시하여 파일을 언 스테이징합니다.

Hg hg resolve -l (해결 된 / 해결되지 않은 충돌이있는 파일 나열)
Git git status-완전히 병합 된 파일은 충돌이없는 파일이 인덱스에 자동으로 추가됩니다.

Hg hg resolve FILE (병합 후 파일을 다시 병합하려고 시도 함) 내가 아는 재 병합에 해당하는
Git이 없습니다.


참고 : Git과 Mercurial의 가장 큰 차이점 중 하나는 인덱스 또는 스테이징 영역 의 명시 적 존재입니다 .

에서 힘내 사용자에 대한 의욕 :

Git은 인덱스 또는 스테이징 영역의 개념을 노출 하는 유일한 DistributedSCM 입니다. 다른 사용자는이를 구현하고 숨길 수 있지만 다른 경우에는 사용자가이를 인식하거나 처리 할 필요가 없습니다.

Mercurial's rough equivalent is the DirState, which controls working copy status information to determine the files to be included in the next commit. But in any case, this file is handled automatically.
Additionally, it is possible to be more selective at commit time either by specifying the files you want to commit on the command line or by using the RecordExtension.

If you felt uncomfortable dealing with the index, you are switching for the better ;-)


The trick is, you really need to understand the index to exploit fully Git. As this article from May 2006 reminds us then (and it is still true now):

“If you deny the Index, you really deny git itself.”

Now, that article contains many commands which are now simpler to use (so do not rely on its content too much ;) ), but the general idea remains:

You are working on a new feature and starts to make minor modifications on a file.

# working, add a few lines
$ git add myFile
# working, another minor modification
$ git add myFile

At this point, your next commit will embark 2 minor modifications in the current branch

# working, making major modification for the new features
# ... damn! I cannot commit all this in the current branch: nothing would work

$ git commit

Only records the changes added to the staging area (index) at this point, not the major changes currently visible in your working directory.

$ git branch newFeature_Branch
$ git add myFile

The next commit will record all the other major changes in the new branch 'newFrature_Branch'.

Now, adding interactively or even splitting a commit are features available with Mercurial, through the 'hg record' command or other extensions: you will need to install RecordExtension, or the CrecordExtension.
But this is not part of the normal workflow for Mercurial.

Git views a commit as a series of "file content changes", and let you add those changes one at a time.
You should study that feature and its consequences: Most of Git power (like the ability to easily revert a merge (or bisect the problem, or revert a commit), contrary to Mercurial) comes from that "file content" paradigm.


tonfa (in in profile: "Hg dev, pythonist": figures...) chimed in, in the comments:

There's nothing fundamentally "git-ish" in the index, hg could use an index if it was deemed valuable, in fact mq or shelve already do part of that.

Oh boy. Here we go again.

First, I am not here to make one tool looks better than another. I find Hg great, very intuitive, with a good support (especially on Windows, my main platform, although I work on Linux and Solaris8 or 10 too).

The index is actually front and center in the way Linus Torvalds works with a VCS:

Git used explicit index updates from day 1, even before it did the first merge. It's simply how I've always worked. I tend to have dirty trees, with some random patch in my tree that I do not want to commit, because it's just a Makefile update for the next version

Now the combination of the index (which is not a notion seen only in Git), and the "content is king" paradigm makes it pretty unique and "git-ish":

git is a content tracker, and a file name has no meaning unless associated to its content. Therefore, the only sane behavior for git add filename is to add the content of the file as well as its name to the index.

Note: the "content", here, is defined as follows:

Git's index is basically very much defined as

  • sufficient to contain the total "content" of the tree (and this includes all metadata: the filename, the mode, and the file contents are all parts of the "content", and they are all meaningless on their own!)
  • additional "stat" information to allow the obvious and trivial (but hugely important!) filesystem comparison optimizations.

So you really should see the index as being the content.

The content is not the "file name" or the "file content" as separate parts. You really cannot separate the two.
Filenames on their own make no sense (they have to have file content too), and file content on its own is similarly senseless (you have to know how to reach it).

What I'm trying to say is that git fundamentally doesn't allow you to see a filename without its content. The whole notion is insane and not valid. It has no relevance for "reality".

From the FAQ, the main advantages are:

  • commit with a fine granularity
  • help you to keep an uncommited modification in your tree for a reasonably long time
  • perform several small steps for one commit, checking what you did with git diff, and validating each small step with git add or git add -u.
  • allows excellent management of merge conflicts: git diff --base, git diff --ours, git diff --theirs.
  • allows git commit --amend to amend only the log message if the index hasn't been modified in the meantime

I personally think this behavior shouldn't be the default, you want people to commit something that is tested or at least compiled

While you are right in general (about the "tested or compiled" part), the way Git allows you for branching and merging (cherry-picking or rebasing) allows you to commit as often as you want in a temporary private branch (pushed only to remote "backup" repository), while re-doing those "ugly commits" on a public branch, with all the right tests in place.


Mercurial:

hg init . # start a project in the current directory
hg addremove # look for any added or deleted files
hg commit -m "comment" # commit any uncomitted changes
hg status # what have i changed since the last commit?

Git Equivalents:

git init
git add -A
git commit -am "comment" # -a is not necessary along with the above add -A
git status

It is roughly the same, without addremove:

git init # Start a project in the current directory
git status # Displays both changes and added/removed files
git commit -m "comment" # commit any uncommited changes

However, these are commands you would use when working alone. You get into the neat stuff when you want to merge your changes with other people's work with git pull and git push, and related commands.

참고URL : https://stackoverflow.com/questions/1450348/git-equivalents-of-most-common-mercurial-commands

반응형