Instantly share code, notes, and snippets.

View git_add_rm_files.sh
git rm $(git ls-file --deleted);
View reset-file.sh
git checkout c5f567 -- file1/to/restore file2/to/restore
View f-br.sh
# to fetch (obtain references to) all origin branches
git fetch origin
# to see all branches
git branch -a
git branch -a | grep foo
View puts.rb
# puts string was not working, these are a few work arounds
def puts(s)
Rails.logger.info(s)
end
File.open("debug.txt", ""){|f|f.write('foo')}
raise "foo"
View show_untracked_files.sh
git ls-files --others --exclude-standard
View files-changed.sh
git diff --name-only
View no-whitespace.sh
git diff -w # ignores whitespace differences
# note that this will see no difference in "asc" and "a s c"
git diff --ignore-space-at-eol # ignores all space at the end of line
# this is most likely what you want.
# these options also work with git show
git show 2ert4d9 --ignore-all-space
git show 2ert4d9 --ignore-space-change
View suppress.sh
git log @{u}.. 2> /dev/null
# if git log fails, it will fail silently.
# 2> means redirecting the output of stderr.
# https://stackoverflow.com/questions/40714202/what-is-the-meaning-of-2-in-2-dev-null
View compare.sh
git log @{u}..
# @{u} is a shortcut to the upstream branch that this current branch is tracking.
# .. specifies a range of commits.
# same as saying git log @{u}..HEAD
# comparing where HEAD is on this branch to where HEAD is on the remote tracked branch.s
# https://stackoverflow.com/questions/19474577/what-does-the-argument-u-mean-in-git/19474730#19474730
View chown.sh
sudo chown -R $USER ~/projects/kaa-api/log