To display a list of your current Git remotes and...
...their endpoints, you can say git remote -v The output looks like this: brady8 https://github.com/brady8/aegis.git (fetch) brady8 https://github.com/brady8/aegis.git (push) origin git@github.com:makandra/aegis.git (fetch) origin git@github.com:makandra/aegis.git...
You might get the above error message when cloning certain git repositories (for example the rails repository). It indicates that there is a malformed timestamp in some commit, and your...
...git installation is configured to validate it. As a workaround, you can disable the validation using git config --global fetch.fsckobjects false This settings seems to be the default for most...
If git gives you an error message such as "fatal: bad config file line 123 in .git/config" after you tried to checkout a branch with a very long branch name...
...you very likely come across a bug in git version < 1.8. You should ask someone with a newer git version (someone pushed the branch right?) to rename the branch to...
Make a new commit now, with a message like "fix". Do a git rebase -i OLD_COMMIT~ In the editor window that opened, move the "fix" commit directly...
...fixup". Save the file. If there are conflicts, solve them, add them, and do git rebase --continue
...to checkout the branch groups, you can simply say this in recent versions of Git: git fetch origin git checkout groups This will automatically track origin/groups from a local branch...
In older Git versions you need to say this: git fetch origin git checkout --track origin/groups
This will stash all modifications that you did not git add: git stash -k Note that newly created (and non-added) files will remain in your working directory unless you...
...also use the -u switch. git stash -k -u Also, your working directory must be clean (i.e. all changes need to be added) when you git stash pop later on...
If you say git stash, your stashed changes will be identified with an automatically generated message: $ git stash Saved working directory and index state WIP on master: 77af0df Merge branch...
...if you stash often. Of course, there is a way to do it with git: $ git stash save doing crazy things Saved working directory and index state On master: doing...
...ID 1] My feature You can revert a single commit using the following syntax: git revert commit_sha2 To revert changes that are split across multiple commits, use the --no...
git revert --no-commit commit_sha3 git revert --no-commit commit_sha1 git commit -m "Revert Story...
...However, this tool has some bugs. To only import the trunk (with complete history): git svn clone http://host/svn/... Create a .gitignore after the conversion. Turn the folder into a...
...git repository as described here...
...another branch or past commit without doing a complete checkout, you can either use git show branch:file git show commit:file to display, or check out the file into...
...your working directory with git checkout branch -- file git checkout commit -- file
...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
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...
...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...
If your git index for some reason becomes invalid, no need to worry. Your index is corrupt when you see this error running usual git commands like git pull, git...
...there. Fix it by first removing the index file, then resetting the branch: rm .git/index git reset You should be all good now. To be safe, make a backup 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...
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...
Grit gives you object oriented read/write access to Git repositories via Ruby...
...a web based code review system, facilitating online code reviews for projects using the Git version control system...
...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
...you select from a list of all started and finishes stories. Then it runs git commit with the generated message (i.e. all staged changes will be commited). When running for...
Random list of useful git commands for advanced users. I found some of them useful...