Cheatsheet: Git Commands, SSH Key Management, and Clipboard Operations
Git Commands: Moving Changes to a New Branch
-
Check Current Branch:
-
Create and Switch to a New Branch:
-
Stage Changes:
-
Commit Changes:
-
Push Changes to New Branch:
-
Switch Back to the Original Branch:
-
Update Original Branch with Remote Changes:
Rebase vs. Merge
-
Rebase:
- Reapplies changes on top of another branch.
- Cleaner, linear history but rewrites commit history.
- Command:
git rebase branch-name
-
Merge:
- Combines changes from one branch into another.
- Maintains history of both branches, creates a merge commit.
- Command:
git merge branch-name
SSH Key Management
-
Install OpenSSH Server (if not installed):
-
Enable SSH Service to Start on Boot:
-
Start SSH Service Immediately:
-
Verify SSH Service Status:
-
Copy Public Key to Server (using
ssh-copy-id
): -
Manually Add Public Key to
authorized_keys
:- Connect to server:
- Create
.ssh
directory: - Add public key:
- Set permissions:
-
Test SSH Connection to GitHub:
-
Check and Update Remote URL:
Clipboard Operations
-
Install
xclip
: -
Install
xsel
: -
Copy File Contents to Clipboard:
-
Using
xclip
: -
Using
xsel
:
-
-
Extract and Clean Public SSH Key:
-
Using
awk
: -
Using
sed
: -
Using
cut
: -
Using
tr
:
-
-
Copy Cleaned Key to Clipboard:
-
Using
xclip
: -
Using
xsel
:
-
-
Paste Key in Terminal:
- Use
Ctrl + V
orShift + Insert
.
- Use
This cheatsheet covers Git branching and remote operations, managing SSH keys, and clipboard operations on Ubuntu.