...your ~/.bashrc: export PS1='\[\033[01;32m\]\h\[\033[01;34m\] \w\[\033[31m\]$(__git_ps1 "(%s)") \[\033[01;34m\]$\[\033[00m\] ' Reload the changes by saying source ~/.bashrc

...some customized prompts that also show the current Git prompt, see the examples section at the bottom of our bash prompt customizing card...

durdn.com

This article contains: Making ‘git diff’ wrap long lines Set a global proxy Clone only a specific branch Diff file against remote branch List all deleted files in the repository...

...Search for a string in all revisions of entire git history Apply a patch from another (unrelated) local repository Making a more recent branch the new master Adding an initial...

...sometimes want to use an external tool for viewing a diff, you can use git difftool. E.g. viewing git diff with meld: git difftool --tool=meld For each file in...

...a file by mistake, you can unstage it (but keep local changes) by saying git reset HEAD path/to/file This is also what git status will tell you.

...for conflicts, too, if git checkout -- does not (although git tells you it would...

You can tell git to ignore different kinds and amounts of whitespace when merging or cherry-picking. This often occurs when you changed indentation, or converted tabs to spaces.

git merge -Xignore-space-change or git cherry-pick -Xignore-space-change

...for your project. Go to Project Settings / Version Control and set the director to Git...

makandra dev
stackoverflow.com

When there's a Gemfile.lock in your working directory that you cannot remove by either checkout, reset [--hard], stash, probably...

Create a directory mkdir ~/.aws Initialise git repository cd ~/.aws && git init Create a git branch with a name you want (e.g. development for the aws development account credentials).

...you want to manage a new account you just have to add a new git branch. Add this to your bashrc: export EC2_PRIVATE_KEY=~/.aws/pk-ec2.pem export EC2_CERT=~/.aws/cert-ec2.pem...

ohshitgit.com

Git is hard: screwing up is easy, and figuring out how to fix your mistakes is fucking impossible. Git documentation has this chicken and egg problem where you can't...

It's like a GUI for the famous git add [-p]. Select files with the up/down-keys and hit u for staging/unstaging the whole file Enter for showing the diff of...

By default git diff highlights whole lines as changes. To diff on a word-by-word basis you can say: git diff --color-words To diff on a character-by...

...character basis you can say: git diff --color-words...

unix.stackexchange.com

As described by the linked Stackoverflow answer, run these commands: sudo add-apt-repository ppa:git-core/ppa -y sudo apt-get update sudo apt-get install git

...This will get you Git 2.6.4 (as of Dec 2015). Troubleshooting If you don't have add-apt-repository yet, install it with: sudo apt-get install python-software-properties...

...this command to list the authors of the most recent commit of each branch: git for-each-ref --format='%(committerdate) %09 %(authorname) %09 %(refname)' | sort -k5n -k2M -k3n -k4n

makandra dev
github.com

Git commands tend to come in groups. Avoid typing git over and over and over by running them in a dedicated git shell. You might want to run git config...

...global help.autocorrect true before using gitsh. This will silently swallow a muscle-memory "git" prefix to your commands inside the git shell...

geewax.org

When we started using git to manage our source code at work, we actually jumped in a little bit too fast. It seems like there is a lot of writing...

...about how you can do lots of really neat things with git, but no real guide about one particular way of using git for your project. This post is going...

makandra dev

tmp/* storage/* db/*.sqlite3 db/schema.rb db/structure.sql public/system .project .idea/ public/javascripts/all* public/stylesheets/all* public/stylesheets/*.css config/database.yml *~ *#* .#* .DS_Store webrat-*.html

This will list all branches matching your query as input options for git checkout greckout ar 1) ar/cache-api-keys-1098 2) ar/add-categories-object-to-tv-show-1382...

gitready.com

...them into your local branches, etc. You can see the remote branches by saying git branch -r Or, if you want to see both local and remote branches, you can...

You can seriously speed up deployments with Capistrano when using a local git repository on the server you are deploying to. Simply add set :deploy_via, :remote_cache

...exclude, [ '.git' ] to your config/deploy.rb and Capistrano will create a clone in shared/cached-copy. This will be updated using git pull when deploying which transfers less bytes and is usually much...

Our gitpt script to generate git commits from Pivotal Tracker stories has been tweaked and polished and is now part of the geordi gem. Install the freshly released version...

linux.die.net

...out which of your local commits are not on the remote server do this: git cherry -v The -v option prints out the commit messages. Without it you will see...

...only the SHA1 codes. You may also compare against another (upstream) branch like that: git cherry -v origin/somebranch This tool is especially useful when you have a ton of commits...

...can change how many lines are shown above and below a changed section. E.g. git diff -U10 will show 10 lines above and below...

For every commit you need to revert, starting at the most recent, do: git revert -n [COMMIT] #revert, but don't automatically commit ... #fix any conflicts git reset #unstage...

git add -p #this will ask you for every change, whether you want to go through with the revert (i.e. "y" will revert, "n" will not; "?" for help...

stackoverflow.com

While git branch will show you all branches and highlight the current one with an asterisk, it can be too cumbersome when working with lots of branches.

...the branch you are currently on, use: git rev-parse --abbrev-ref HEAD