Compare commits

...

5 Commits

9 changed files with 330 additions and 339 deletions

View File

@ -414,8 +414,7 @@ $ git push --force-with-lease [remote] [branch]
If you haven't pushed, to reset Git to the state it was in before you made your last commit (while keeping your staged changes):
```
(my-branch*)$ git reset --soft HEAD@{1}
(my-branch)$ git reset --soft HEAD^
```
This only works if you haven't pushed. If you have pushed, the only truly safe thing to do is `git revert SHAofBadCommit`. That will create a new commit that undoes all the previous commit's changes. Or, if the branch you pushed to is rebase-safe (ie. other devs aren't expected to pull from it), you can just use `git push --force-with-lease`. For more, see [the above section](#deleteremove-last-pushed-commit).
@ -903,10 +902,10 @@ Confirm that you haven't pushed your changes to the server.
#
```
One way of resetting to match origin (to have the same as what is on the remote) is to do this:
One way of resetting branch `my-branch` to match `origin/my-branch` (to have the same as what is on the remote) is to do this:
```sh
(main)$ git reset --hard origin/my-branch
(my-branch)$ git reset --hard origin/my-branch
```
<a name="commit-wrong-branch"></a>
@ -1278,7 +1277,7 @@ Use `git log` to find the commit where you want to split. Then do the following:
(original_branch)$ git reset --hard <sha1 split here>
```
If you had previously pushed the `original_branch` to remote, you will need to do a force push. For more information check [Stack Overlflow](https://stackoverflow.com/questions/28983458/how-to-split-a-branch-in-two-with-git/28983843#28983843)
If you had previously pushed the `original_branch` to remote, you will need to do a force push. For more information check [Stack Overflow](https://stackoverflow.com/questions/28983458/how-to-split-a-branch-in-two-with-git/28983843#28983843)
## Rebasing and Merging
@ -1829,12 +1828,16 @@ Assuming you want to compare last commit with file from commit c5f567:
```sh
$ git diff HEAD:path_to_file/file c5f567:path_to_file/file
# or
$ git diff HEAD c5f567 -- path_to_file/file
```
Same goes for branches:
If you are going to compare changes between the tips of the `main` and the `staging` branches:
```sh
$ git diff main:path_to_file/file staging:path_to_file/file
# or
$ git diff main staging -- path_to_file/file
```
### I want Git to ignore changes to a specific file

View File

@ -201,8 +201,7 @@ $ git push --force-with-lease [remote] [branch]
Si no has subido tus cambios, para resetear Git al estado en el que estaba antes de realizar tu último commit (mientras mantengas tus cambios en staging):
```
(my-branch*)$ git reset --soft HEAD@{1}
(my-branch)$ git reset --soft HEAD^
```
Esto solo funciona si no subiste tu commit. Si lo hiciste, la única cosa segura por hacer es `git revert SHAofBadCommit`. Eso creará un nuevo commit que deshace todos los cambios del anterior commit. O, si la rama que subiste es segura ante reorganizaciones (ej. otros desarrolladores no esperan recibir cambios desde ahí), puedes usar `git push --force-with-lease`. Para más, mira [la sección de arriba](#quiero-borrar-o-remover-mi-ultimo-commit).
@ -515,7 +514,7 @@ Confirma que no ha enviado sus cambios al servidor.
Una forma de reiniciar para hacer coincidir el origin (tener lo mismo que lo que está en el control remoto) es hacer esto:
```sh
(main) $ git reset --hard origin / my-branch
(my-branch) $ git reset --hard origin/my-branch
```
### Hice commit a main en lugar de una nueva rama

View File

@ -239,7 +239,7 @@ $ git push --force-with-lease [remote] [branche]
Si vous n'avez pas poussé, pour réinitialiser Git vers l'état dans lequel il était avant que vous ne fassiez votre dernier commit (tout en gardant vos changements) :
```
(ma-branche*)$ git reset --soft HEAD@{1}
(ma-branche)$ git reset --soft HEAD^
```
Cela ne marchera que si vous n'avez pas poussé. Si vous avez poussé, la seule vraie chose sécurisée à faire est `git revert SHAduMauvaisCommit`. Cela créera un nouveau commit qui annule tous les changements du commit en question. Ou, si la branche vers laquelle vous avez poussé est "rebase-safe" (en d'autres termes, les autres développeur·euse·s ne la récupéreront pas), vous pouvez juste lancer `git push --force-with-lease`. Pour plus d'informations, jetez un œil [à la section ci-dessus](#je-veux-supprimer-ou-retirer-mon-dernier-commit).
@ -576,7 +576,6 @@ Assurez-vous que vous n'avez pas poussé vos modifications sur le serveur.
`git status` devrait vous indiquer combien de commits en avance vous êtes par rapport à origin :
```sh
(my-branch)$ git status
(ma-branche)$ git status
# On branch ma-branche
# Your branch is ahead of 'origin/my-branch' by 2 commits.
@ -587,7 +586,7 @@ Assurez-vous que vous n'avez pas poussé vos modifications sur le serveur.
Une des façons de faire pour réinitialiser votre branche afin qu'elle corresponde à origin (afin d'avoir la même chose que le dépôt distant) est de lancer ceci :
```sh
(main)$ git reset --hard origin/ma-branche
(ma-branche)$ git reset --hard origin/ma-branche
```
<a name="commit-wrong-branch"></a>
@ -1450,12 +1449,16 @@ Supposons que vous voulez comparer le dernier commit avec le fichier du commit `
```sh
$ git diff HEAD:path_to_file/file c5f567:path_to_file/file
# ou
$ git diff HEAD c5f567 -- path_to_file/file
```
Il en est de même pour les branches :
```sh
$ git diff main:path_to_file/file staging:path_to_file/file
# ou
$ git diff main staging -- path_to_file/file
```
### Je veux que Git ignore les changements d'un fichier spécifique

View File

@ -369,7 +369,7 @@ $ git push --force-with-lease [remote] [branch]
まだコミットをプッシュしていない場合は、次のようにして(ステージされた編集はそのままで)直前のコミットをする前の状態に Git をリセットできます。
```
(my-branch*)$ git reset --soft HEAD@{1}
(my-branch)$ git reset --soft HEAD^
```
これはプッシュしていない場合にのみ有効な方法です。
@ -919,7 +919,7 @@ $ git reset --hard c5bc55a
origin と同じ状態にリセットする(リモートと同じ状態にする)方法の一つは次の通りです。
```sh
(main)$ git reset --hard origin/my-branch
(my-branch)$ git reset --hard origin/my-branch
```
<a name="commit-wrong-branch"></a>
@ -1873,12 +1873,16 @@ $ git push origin refs/tags/<tag-name>
```sh
$ git diff HEAD:path_to_file/file c5f567:path_to_file/file
# または
$ git diff HEAD c5f567 -- path_to_file/file
```
ブランチでも同様です。
```sh
$ git diff main:path_to_file/file staging:path_to_file/file
# または
$ git diff main staging -- path_to_file/file
```
### 特定のファイルの変更を無視したい

View File

@ -237,7 +237,7 @@ $ git push --force-with-lease [remote] [branch]
아직 푸시 안했으면, 리셋으로 마지막 커밋 전 상태로 돌아가요. (변경점은 스테이지에 두고서)
```
(my-branch*)$ git reset --soft HEAD@{1}
(my-branch)$ git reset --soft HEAD^
```
이 방법은 푸시를 안 했을 때만 동작해요. 푸시를 했으면, 안전한 방법은 `git revert SHAofBadCommit` 한가지 밖이에요.
@ -547,7 +547,7 @@ $ git reset --hard c5bc55a
오리진(리모트과 같은 상태의)로 맞추는 리셋을 하는 방법 중 하나는:
```sh
(main)$ git reset --hard origin/my-branch
(my-branch)$ git reset --hard origin/my-branch
```
<a name="commit-wrong-branch"></a>
@ -1409,12 +1409,16 @@ c5f567 한 단계전으로 복구하고 싶다면, c5f567~1로 적어줘요:
```sh
$ git diff HEAD:path_to_file/file c5f567:path_to_file/file
# 아니면 짧게:
$ git diff HEAD c5f567 -- path_to_file/file
```
브랜치도 같은 방법으로:
```sh
$ git diff main:path_to_file/file staging:path_to_file/file
# 아니면 짧게:
$ git diff main staging -- path_to_file/file
```
## 설정

View File

@ -341,8 +341,7 @@ $ git push --force-with-lease [remote] [branch]
Если Вы еще не опубликовали коммит, то просто сбросьте ветку в состояние перед Вашим последним коммитом (подготовленные изменения не пропадут):
```
(my-branch*)$ git reset --soft HEAD@{1}
(my-branch)$ git reset --soft HEAD^
```
Это работает, если Вы еще не сделали `push`. Если Вы уже сделали `push`, то единственный по-настоящему безопасный способ это `git revert SHAofBadCommit`. Это создаст новый коммит, который отменит все изменения предыдущего коммита. Или, если ветка, в которую вы делаете `push` безопасна для перезаписи (т.е. не предполагается, другие разработчики будут стягивать из нее изменения), то просто используйте `git push --force-with-lease`. Подробнее см. [в этом пункте выше](#delete-pushed-commit).
@ -808,7 +807,7 @@ $ git reset --hard c5bc55a
Один из способов сбросить до источника (чтобы иметь то же, что и в удаленном репозитории):
```sh
(main)$ git reset --hard origin/my-branch
(my-branch)$ git reset --hard origin/my-branch
```
<a name="commit-wrong-branch"></a>
@ -1681,12 +1680,16 @@ $ git push origin refs/tags/<tag-name>
```sh
$ git diff HEAD:path_to_file/file c5f567:path_to_file/file
# или
$ git diff HEAD c5f567 -- path_to_file/file
```
Аналогично для веток:
```sh
$ git diff main:path_to_file/file staging:path_to_file/file
# или
$ git diff main staging -- path_to_file/file
```
### Я хочу, чтобы Git игнорировал изменения в определенном файле

View File

@ -361,8 +361,7 @@ $ git push --force-with-lease [remote] [branch]
Nếu bạn chưa push, để đảo ngược Git về trạng thái trước khi bạn thực hiện commit mới nhất (trong khi vãn giữ các thay đổi trong stage) hãy chạy lệnh:
```
(my-branch*)$ git reset --soft HEAD@{1}
(my-branch)$ git reset --soft HEAD^
```
Cách này chỉ phù hợp nếu bạn chưa push. Nếu bạn đã push, điều thực sự an toàn nhất cần làm là `git revert SHAcủaCommitSai`. Lệnh này sẽ tạo một commit mới để quay trở lại thay đổi của commit trước đó. Hoặc nếu nhánh bạn đã push là rebase-safe (không có kỳ vọng các dev khác sẽ pull từ nó), bạn chỉ có thể sử dụng `git push --force-with-lease`. Để biết thêm, hãy xem [phần trên](#delete-pushed-commit).
@ -853,7 +852,7 @@ Kiểm tra rằng bạn chưa push các thay đổi của mình đến server.
Một cách để reset về origin (để có nhánh giống như trên remote) là chạy lệnh:
```sh
(main)$ git reset --hard origin/my-branch
(my-branch)$ git reset --hard origin/my-branch
```
<a name="commit-wrong-branch"></a>
@ -1776,12 +1775,16 @@ Giả sử bạn muốn so sánh commit cuối cùng với tệp từ commit c5f
```sh
$ git diff HEAD:path_to_file/file c5f567:path_to_file/file
# hoặc
$ git diff HEAD c5f567 -- path_to_file/file
```
Cũng giống khi so sánh nhánh nhánh:
```sh
$ git diff main:path_to_file/file staging:path_to_file/file
# hoặc
$ git diff main staging -- path_to_file/file
```
### Tôi muốn Git bỏ qua những thay đổi đối với một tệp cụ thể

View File

@ -163,8 +163,7 @@ $ git push -f [remote] [branch]
如果你还没有推到远程, 把Git重置(reset)到你最后一次提交前的状态就可以了(同时保存暂存的变化):
```
(my-branch*)$ git reset --soft HEAD@{1}
(my-branch)$ git reset --soft HEAD^
```
这只能在没有推送之前有用. 如果你已经推了, 唯一安全能做的是 `git revert SHAofBadCommit` 那会创建一个新的提交(commit)用于撤消前一个提交的所有变化(changes) 或者, 如果你推的这个分支是rebase-safe的 (例如: 其它开发者不会从这个分支拉), 只需要使用 `git push -f` 更多, 请参考 [the above section](#deleteremove-last-pushed-commit)。
@ -376,7 +375,7 @@ $ git reset --hard c5bc55a
一种方法是:
```sh
(main)$ git reset --hard origin/my-branch
(my-branch)$ git reset --hard origin/my-branch
```
<a name="commit-wrong-branch"></a>

File diff suppressed because it is too large Load Diff