Skip to content

Instantly share code, notes, and snippets.

@SuperShinyEyes
Last active December 7, 2017 13:33
Show Gist options
  • Save SuperShinyEyes/01db48dfe04a541ab4ed91a52e442c8e to your computer and use it in GitHub Desktop.
Save SuperShinyEyes/01db48dfe04a541ab4ed91a52e442c8e to your computer and use it in GitHub Desktop.
All git stuffs

List all tracked files

git ls-tree -r master --name-only

cd path/to/project-b git remote add project-a path/to/project-a git fetch project-a git merge --allow-unrelated-histories project-a/master # or whichever branch you want to merge git remote remove project-a

Delete remote branch

git push origin --delete branch_name

Simple git log

git log --graph --all --format=format:"(%h) %ci <%ce>%n%s"

Removing a file added in the most recent unpushed commit

git rm --cached giant_file
# Stage our giant file for removal, but leave it on disk

git commit --amend -CHEAD
# Amend the previous commit with your change
# Simply making a new commit won't work, as you need
# to remove the file from the unpushed history as well

git push

Include an empty folder

Contents of the top-most .gitignore:

# ignore everything except .gitignore and folders that I care about:
*
!images*
!.gitignore

In the nested images folder this is your .gitignore:

# ignore everything except .gitignore
*
!.gitignore

Note, you must spell out in the .gitignore the names of the folders you don't want to be ignored in the folder where that .gitignore is located. Otherwise they are, obviously, ignored.

Your folders in the repo will, obviously, NOT be empty, as each one will have .gitignore in it, but that part can be ignored, right. :)

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