Skip to content

Instantly share code, notes, and snippets.

View marcusshepp's full-sized avatar
🎯
Focusing

Marcus Shepherd marcusshepp

🎯
Focusing
View GitHub Profile
@marcusshepp
marcusshepp / windowspowershell.md
Last active February 17, 2022 15:17
Windows Powershell

powershell

Files and Directories

create a new file with new-item

new-item -name 'foobar.txt' -itemtype file -path . -value 'foobarpop'

create a new directory with new-item

new-item -name 'foobar' -itemtype directory -path .

moving items with move-item

@marcusshepp
marcusshepp / git_add_rm_files.sh
Last active December 7, 2017 14:57
staging deleted files by listing them then sending the list into git rm
git rm $(git ls-file --deleted);
@marcusshepp
marcusshepp / reset-file.sh
Created August 29, 2017 13:21
reset file back to commit hash
git checkout c5f567 -- file1/to/restore file2/to/restore
@marcusshepp
marcusshepp / f-br.sh
Created August 24, 2017 13:51
finding branches
# to fetch (obtain references to) all origin branches
git fetch origin
# to see all branches
git branch -a
git branch -a | grep foo
@marcusshepp
marcusshepp / puts.rb
Created August 23, 2017 20:46
puts not working in rails project
# 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"
@marcusshepp
marcusshepp / show_untracked_files.sh
Created August 21, 2017 20:28
git list untracked files
git ls-files --others --exclude-standard
@marcusshepp
marcusshepp / files-changed.sh
Created August 21, 2017 20:26
git diff list only names of files changed
git diff --name-only
@marcusshepp
marcusshepp / no-whitespace.sh
Last active August 21, 2017 19:00
git diff without white space
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
@marcusshepp
marcusshepp / suppress.sh
Created August 9, 2017 15:33
suppressing the possible error of a command
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
@marcusshepp
marcusshepp / compare.sh
Last active August 9, 2017 15:34
compare local branch git log to remote branch
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