Club 15CC

Git ~ 15CC Code

Task Code
Git Show the Date When a File Was First Added to a Git Repo »
git log --format=%aD --follow -- <FILE> | tail -1
bash Piping Two Inputs into a Linux Shell Command »
diff <(git log --oneline origin) <(git log --oneline)
Git Clear the Index of Stage Files »
git reset HEAD
Git Removing the Working Tree from a Repo (Making it “Bare”) »
# Repo in myRepo/
mv myRepo/.git myRepo.git
rm -fr myRepo
cd myRepo.git
git config core.bare true
Git Delete a remote branch in Git » Basically, push "nothing" to the branch....
git push origin :branch-to-delete
Git Find a dangling commit and reset current branch to it » Useful if you want to undo a `git reset --hard...
$ git fsck --lost-found
dangling commit e7e3a2e82abd4f7160618b7f60b9e141b69fb153

# or...
$ git reflog
fdc6198 HEAD@{0}: cherry-pick: Adds additional DEBUG macros...
ab67f92 HEAD@{1}: checkout: moving from ARC-version to master
e7e3a2e HEAD@{2}: an undone commit i want to get back

# then
$ git reset --hard e7e3a2e
Git Checkout a file from a previous commit into a new filename in the current tree »
git show HEAD^^:Full/Path/To/File.txt > Dest/Path/File2.txt
Git Useful Git aliases » Credits:...
# .gitconfig in your repo, user or system folder
[alias]
ci = commit
cim = commit -m 
st = status
commit-all = !git add -A && git commit   # long version
cia = !git add -A && git commit          # add/update everything and commit
ciam = !git add -A && git commit -m      
add-all = add -A
aa = add -A
this = !git init && git add . && git commit -m \"initial commit\"    #
unstage = reset HEAD --   # Unstage a specific file
last = log -1 HEAD        # Show last commit
lg = log --oneline -20    # Show last 20 logs as one liners without pagination.
copy-out = !sh -c 'git show $0:"$1" > "$2"' # Checkout a file from a previous commit into a new filename
Git Update latest commit with some things you forgot (or update the commit message) »
# Add the new files / prep the stage as you'd like it to be
git commit --amend