Comments on: Git Cheat Sheet http://www.terminally-incoherent.com/blog/2012/01/16/git-cheat-sheet/ I will not fix your computer. Tue, 04 Aug 2020 22:34:33 +0000 hourly 1 https://wordpress.org/?v=4.7.26 By: Luke Maciak http://www.terminally-incoherent.com/blog/2012/01/16/git-cheat-sheet/#comment-21232 Sun, 22 Jan 2012 05:51:33 +0000 http://www.terminally-incoherent.com/blog/?p=11113#comment-21232

@ Tormod Haugen:

Uh, nice stuff. I like the stash trick.

Oh, another neat thing is:

git rm --cached filename

It removes tracked files from the index and if you commit and push it will purge them from the remote as well. I had to do this for two of my python repos when I realized I was tracking the .pyc files which change at each run.

Reply  |  Quote
]]>
By: Tormod Haugen http://www.terminally-incoherent.com/blog/2012/01/16/git-cheat-sheet/#comment-21208 Tue, 17 Jan 2012 10:09:06 +0000 http://www.terminally-incoherent.com/blog/?p=11113#comment-21208

Rebase. Twice.
(ps. you can use git rebase to destroy stuff.)

1) I work in feature branches, and so there comes a time when your development /master branch is changed (pull someone else’s changes, do a bugfix or something). You then do a “git rebase master” from your feature branch to get up to date, moving the base of your branch along the timeline.

2) Make commits nicer. You do a commit “fix issue 2715”, then minutes later do a commit “fix issue 2715 + added missing file”. Now you want to push this, but that looks… not nice. Do “git rebase -i” (interactive), select which commits to squash, edit commit message and there you have only one commit for that fix. Nice and easy. Don’t do this after pushing to a public repo/branch, as it might cause a space/time anomality.

Also stuff I need to have written down (or needed to have written down):

Removing deleted files from the repository

To find files that are deleted on disk, but exist in the repo – git ls-files –deleted.
To mark those files as deleted in the index – git ls-files –deleted | xargs git rm #remember to commit.
To add all changed (modified + deleted) files to the index – git add -u #this does not add untracked files.

Finding branches that are not merged back to master

git branch -a –no-merged master #shows branches that are not done.

These “tricks” are picked up different places a long time ago. I don’t remember where, other than “google”. Their usage are colored by how I use(d) git – I create branches for features, bugfixes, testing, other peoples public repos. I never do work directly on a project’s master branch, but merge into it when done.

Oh, and “git stash” puts your non-commited changes in a temporary holding stack – nice to do before rebasing or switching around. You can do “git stash apply” or “git stash pop” to get your changes back again.

Reply  |  Quote
]]>