Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Last active May 22, 2024 00:50
Show Gist options
  • Save wilmoore/530c3be09cb72d3407902d9bb30be397 to your computer and use it in GitHub Desktop.
Save wilmoore/530c3be09cb72d3407902d9bb30be397 to your computer and use it in GitHub Desktop.
Software Engineering :: Source Control :: VCS :: Git :: Guides :: Everyday Git

Software Engineering :: Source Control :: VCS :: Git :: Guides :: Everyday Git

⪼ Made with 💜 by Polyglot.

related

About

cd -
git checkout -
git pull
git what
code .
» git push --set-upstream origin HEAD

Don't Panic

TBD

Inspiration

Authentication

Generating & Configuring SSH Keys

See SSH » How to SSH Properly (gravitational.com)

» ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/github-(date -u +"%Y%m%dT%H%M%SZ").key -C '[email protected]'
» ssh -T [email protected]

Configuration

ReWriting https URLs to SSH URLs

[url "[email protected]:"]
    insteadOf = https://github.azc.ext.hp.com/

Now, when you do this:

» git clone https://github.azc.ext.hp.com/codeway/docker-image-golang-quickstart.git 

It will be re-written as if you had written it as:

» git clone [email protected]:codeway/docker-image-golang-quickstart.git

List Recently Changed Files

git log --stat

Accept Their Incoming Changes

git pull origin refactor-integrations
git checkout --theirs src/entity/MicrosoftTeams.ts
git checkout --theirs src/repos/integration.repo.ts

git open

» which git-open
/Users/wmoore/.config/bin/git-open
» type git-open
git-open is /Users/wmoore/.config/bin/git-open
» cat /Users/wmoore/.config/bin/git-open
#!/usr/bin/env sh
open `echo 'https://'$(git remote -v | grep '(fetch)' | awk -F '[@ ]' '{ print $2 }' | tr ':' '/')`

image

`` » git diff HEAD..PROJ-NNNNN -- src/components/sidebar/index.ts


## [`git show`](https://www.atlassian.com/git/tutorials/git-show)

## `git remote -v`

## `git push --set-upstream origin HEAD`

## `git checkout -`

## `git checkout NAME origin/NAME`

## `git what`

## `git annotate`

## `git log --stat`

## `git diff --staged`

## `git restore <filepath>`

## `git reset --hard HEAD`
> [How do I undo the most recent local commits in Git?](https://stackoverflow.com/a/77741847/128346)

## `git branch`
- list branch
- delete branch locally
- delete branch remotely
- rename branch (`git branch -M main`)
- [You can rename a local Git branch using the following command](https://stackoverflow.com/a/14436012/128346)

## `git add .`

## `git commit --amend`
> [Changing the Last Commit](https://www.atlassian.com/git/tutorials/rewriting-history)

### variations
###### `git commit --amend -m "an updated commit message"`

## `git bisect`

## `git fetch -a`

## `git remote add origin [email protected]:wilmoore/name.git`

## `git init`

## `git status`

## `git commit`

## `git stash`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment