2021-07-27 20:07:51 +00:00
|
|
|
---
|
|
|
|
author: Alvie Rahman
|
|
|
|
date: \today
|
2021-08-23 14:25:05 +00:00
|
|
|
title: Git
|
2021-08-15 19:44:51 +00:00
|
|
|
tags: [ linux, programming, git ]
|
2021-07-27 20:07:51 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
# Fix detached head
|
|
|
|
|
2021-09-01 12:22:35 +00:00
|
|
|
From <https://stackoverflow.com/a/10229202>:
|
2021-07-27 20:07:51 +00:00
|
|
|
|
|
|
|
## To Delete Changes
|
|
|
|
|
|
|
|
```
|
|
|
|
git checkout main
|
|
|
|
```
|
|
|
|
|
|
|
|
## To Keep Changes
|
|
|
|
|
|
|
|
```
|
|
|
|
git branch temp
|
|
|
|
git checkout main
|
|
|
|
git pull . temp
|
|
|
|
git branch -D temp
|
|
|
|
```
|
2021-09-01 12:22:35 +00:00
|
|
|
|
|
|
|
# Retroactively Sign Commits
|
|
|
|
|
|
|
|
From <https://webdevstudios.com/2020/05/26/retroactively-sign-git-commits/>:
|
|
|
|
|
|
|
|
1.
|
|
|
|
```
|
|
|
|
git rebase -i HEAD~<number of commits to sign>
|
|
|
|
```
|
|
|
|
|
|
|
|
2. Replace `pick` with `reword`:
|
|
|
|
|
|
|
|
In vim: `:%s/^pick/reword/:wq`
|
|
|
|
|
|
|
|
3. Save all commit messages
|
|
|
|
4. Force push to remote
|