Resolving a blocked push
To resolve a blocked push, you must remove the secret from all of the commits it appears in.
- If the secret was introduced by your latest commit, see Removing a secret introduced by the latest commit on your branch.
- If the secret appears in earlier commits, see Removing a secret introduced by an earlier commit on your branch.
Removing a secret introduced by the latest commit on your branch
- Remove the secret from your code.
- To commit the changes, run
git commit --amend --all. This updates the original commit that introduced the secret instead of creating a new commit. - Push your changes with
git push.
Removing a secret introduced by an earlier commit on your branch
-
Examine the error message that displayed when you tried to push your branch, which lists all of the commits that contain the secret.
remote: —— GitHub Personal Access Token —————————————————————— remote: locations: remote: - commit: 8728dbe67 remote: path: README.md:4 remote: - commit: 03d69e5d3 remote: path: README.md:4 remote: - commit: 8053f7b27 remote: path: README.md:4 -
Next, run
git logto see a full history of all the commits on your branch, along with their corresponding timestamps.test-repo (test-branch)]$ git log commit 8053f7b27 (HEAD -> main) Author: Octocat <1000+octocat@users.noreply.github.com Date: Tue Jan 30 13:03:37 2024 +0100 my fourth commit message commit 03d69e5d3 Author: Octocat <1000+octocat@users.noreply.github.com> Date: Tue Jan 30 13:02:59 2024 +0100 my third commit message commit 8728dbe67 Author: Octocat <1000+octocat@users.noreply.github.com Date: Tue Jan 30 13:01:36 2024 +0100 my second commit message commit 6057cbe51 Author: Octocat <1000+octocat@users.noreply.github.com Date: Tue Jan 30 12:58:24 2024 +0100 my first commit message -
Focusing only on the commits that contain the secret, use the output of
git logto identify which commit comes earliest in your Git history.- In the example, commit
8728dbe67was the first commit to contain the secret.
- In the example, commit
-
Start an interactive rebase with
git rebase -i <COMMIT-ID>~1.- For
<COMMIT-ID>, use the commit identified in step 3. For example,git rebase -i 8728dbe67~1.
- For
-
In the editor, choose to edit the commit identified in step 3 by changing
picktoediton the first line of the text.edit 8728dbe67 my second commit message pick 03d69e5d3 my third commit message pick 8053f7b27 my fourth commit message -
Save and close the editor to start the interactive rebase.
-
Remove the secret from your code.
-
Add your changes to the staging area using
git add ..참고
The full command is
git add .:- There is a space between
addand.. - The period following the space is part of the command.
- There is a space between
-
Commit your changes using
git commit --amend. -
Run
git rebase --continueto finish the rebase. -
Push your changes with
git push.
Bypassing push protection
참고
If you don't see the option to bypass a block, you should remove the secret from the commit, or submit a request for "bypass privileges" in order to push the blocked secret. See Requesting bypass privileges.
-
푸시가 차단되었을 때 푸시를 수행한 사용자와 동일한 사용자로 GitHub에서 반환된 URL을 방문합니다. 다른 사용자가 이 URL을 방문하려고 하면
404오류가 발생합니다. -
비밀을 푸시할 수 있어야 하는 이유를 가장 잘 설명하는 옵션을 선택합니다.
-
비밀이 테스트에만 사용되고 위협이 되지 않는 경우 테스트에 사용됨을 클릭합니다.
-
검색된 문자열이 비밀이 아니면 가양성임을 클릭합니다.
-
비밀이 진짜이지만 나중에 수정하려는 경우 나중에 수정을 클릭합니다.
참고
리포지토리에서 비밀 스캔이 사용 설정된 경우, 푸시 보호를 바이패스하는 이유를 지정해야 합니다.
비밀 스캔을 사용 설정하지 않은 퍼블릭 리포지토리에 대하여 푸시하는 경우에도, 사용자 계정에 기본적으로 ON으로 설정된 사용자에 대한 푸시 보호 덕분에 우발적으로 비밀을 푸시하지 않도록 보호됩니다.
사용자에 대한 푸시 보호를 사용하면 GitHub가 퍼블릭 리포지토리에 대한 푸시에 지원되는 비밀이 포함된 경우 해당 푸시를 자동으로 차단하지만, 비밀을 허용하는 이유를 지정하지 않아도 되고, GitHub이(가) 경고를 생성하지도 않습니다. 자세한 내용은 사용자에 대한 푸시 보호 관리을(를) 참조하세요.
-
-
Click Allow me to push this secret.
-
Reattempt the push on the command line within three hours. If you have not pushed within three hours, you will need to repeat this process.
Requesting bypass privileges
-
푸시가 차단되었을 때 푸시를 수행한 사용자와 동일한 사용자로 GitHub에서 반환된 URL을 방문합니다. 다른 사용자가 이 URL을 방문하려고 하면
404오류가 발생합니다. -
"또는 권한 무시 요청"에 설명을 추가합니다. 예를 들어 비밀이 돌려주는 것이 안전하다고 생각하는 이유를 설명하거나 차단을 무시하기 위한 요청의 컨텍스트를 제공할 수 있습니다.
-
요청 제출을 클릭합니다.
-
메일 알림 요청에 대한 응답을 확인하세요. 요청이 검토되고 나면 결정 내용을 알리는 이메일을 받게 됩니다.
- If your request is approved, you can push the commit (or commits) containing the secret to the repository, as well as any future commits that contain the same secret.
- If your request is denied, you need to remove the secret from all commits before pushing again. For information on how to remove a blocked secret, see Resolving a blocked push.