2021-07-27 20:07:51 +00:00
|
|
|
---
|
|
|
|
author: Alvie Rahman
|
|
|
|
date: \today
|
2021-08-23 14:25:05 +00:00
|
|
|
title: Git
|
2022-03-02 01:43:54 +00:00
|
|
|
tags:
|
|
|
|
- linux
|
|
|
|
- programming
|
|
|
|
- git
|
|
|
|
uuid: 8eb93ba5-72e8-4c25-b1f5-02e25408a14d
|
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
|