Skip to content

Instantly share code, notes, and snippets.

@bard86
bard86 / Readme.md
Created April 19, 2020 12:35 — forked from fracz/Readme.md
Restore intentionally deleted commits in Git

Restore intentionally deleted commits in Git (remote)

Situation

  1. You own a Git repository server and the developers do not have access to it (i.e. they can only read & write to the repo, but not gc it).
  2. You had a developer that wrote a project for you.
  3. He got angry for whatever reason and deleted all branches from the remote repo. He also push -fed the master branch leaving only one silly commit there.
  4. He escaped from the country leaving you without any code at all (at least this is what he believe in).
  5. You have never cloned the repo to other machine. There were only two copies of it: the developer's one and the server's one.
@bard86
bard86 / git-recover-branch.md
Created April 19, 2020 12:34 — forked from jbgo/git-recover-branch.md
How to recover a git branch you accidentally deleted

UPDATE: A better way! (August 2015)

As pointed out by @johntyree in the comments, using git reflog is easier and more reliable. Thanks for the suggestion!

 $ git reflog
1ed7510 HEAD@{1}: checkout: moving from develop to 1ed7510
3970d09 HEAD@{2}: checkout: moving from b-fix-build to develop
1ed7510 HEAD@{3}: commit: got everything working the way I want
70b3696 HEAD@{4}: commit: upgrade rails, do some refactoring
@bard86
bard86 / git_clone_ssh
Created April 17, 2020 14:47
Git clone ssh sample
GIT_SSH_COMMAND='ssh -i private_key_file' git clone user@host:repo.git
@bard86
bard86 / bamboo_server.sh
Last active April 25, 2020 09:26
Run Bamboo and Agent
docker network create \
--driver bridge \
--subnet=192.168.16.0/20 \
atlassianNetwork
docker volume create --name bambooVolume
docker run -d -p 8085:8085 -v bambooVolume:/var/atlassian/application-data/bamboo \
--name bamboo \
--network atlassianNetwork \
@bard86
bard86 / command_prompt
Created April 12, 2020 08:36
Add to .bash_profile
export PS1="\u@\h [\W]: \[$(tput sgr0)\]"
@bard86
bard86 / set_hostname.sh
Last active April 11, 2020 11:30
Set MacBook host name
#!/bin/bash
set -e
sudo hostname MacBook.local
scutil --set HostName MacBook.local
@bard86
bard86 / generate-keys.sh
Created April 10, 2020 16:45
Generate ssh public and private key pair
#!/bin/bash
ssh-keygen -t rsa -C "@gmail.com" -f $HOME/.ssh/id_rsa_file
export PATH="/usr/local/opt/openjdk/bin:$PATH"
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"

Demo:

Spoiler warning

Spoiler text. Note that it's important to have a space after the summary tag. You should be able to write any markdown you want inside the <details> tag... just make sure you close <details> afterward.

console.log("I'm a code block!");
@bard86
bard86 / macbook_write_defaults.sh
Created March 26, 2020 17:12
Macbook configuration
#!/bin/bash
set -e
defaults write com.apple.Finder AppleShowAllFiles true