All processes are carried out by opening the terminal and entering Git commands. This is the content from deleting commits in the local repository to reflecting changes in the remote repository.
Deleting Commits While Keeping Changes
git reset HEAD^
Deletes the most recent commit
git reset HEAD~n
Delete the last n commits
Deleting Both Commits and Changes
git reset --hard HEAD^
Deletes the most recent commit
git reset --hard HEAD~n
Delete the last n commits
Checking Branches and Reflecting Changes in the Remote Repository
git branch
You can use this Git command to find out the name of the branch you are working on.
git push origin main --force
If you are not on the main branch, replace main with the name of your branch.
Using a force push(--force) alters the history of the remote repository, so it is advisable to avoid using it unless necessary. If you are working on a branch alone, it may not be an issue, but if other team members are working on the same branch, it could affect their work.
'개인학습 > 개발 환경' 카테고리의 다른 글
[IntelliJ] Ctrl + Shift + F10, Run 단축키 안 될 때 (1) | 2024.12.10 |
---|---|
[IntelliJ] When Ctrl + Shift + F10 doesn't work (0) | 2024.12.09 |
[GitHub] 최근 커밋 완전히 삭제하기 (1) | 2024.11.30 |
[GitHub] VS Code로 깃허브 커밋하기 (1) | 2024.10.26 |
[GitHub] Committing to GitHub using VS Code (3) | 2024.10.25 |