Git Clone from GitHub over https with two-factor authentication

Find out how to fix this here: https://github.com/blog/1614-two-factor-authentication#how-does-it-work-for-command-line-git How does it work for command-line Git? If you are using SSH for Git authentication, rest easy: you don’t need to do anything. If you are using HTTPS Git, instead of entering your password, enter a personal access token. These can be created by going to your … Read more

Git commits are duplicated in the same branch after doing a rebase

Short answer You omitted the fact that you ran git push, got the following error, and then proceeded to run git pull: To git@bitbucket.org:username/test1.git ! [rejected] dev -> dev (non-fast-forward) error: failed to push some refs to ‘git@bitbucket.org:username/test1.git’ hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. … Read more

Git diff to show only lines that have been modified

What you want is a diff with 0 lines of context. You can generate this with: git diff –unified=0 or git diff -U0 You can also set this as a config option for that repository: git config diff.context 0 To have it set globally, for any repository: git config –global diff.context 0

Checkout remote branch using git svn

Standard Subversion layout Create a git clone of that includes your Subversion trunk, tags, and branches with git svn clone http://svn.example.com/project -T trunk -b branches -t tags The –stdlayout option is a nice shortcut if your Subversion repository uses the typical structure: git svn clone http://svn.example.com/project –stdlayout Make your git repository ignore everything the subversion … Read more

Coloring white space in git-diff’s output

With with Git 2.11 (Q4 2016) and after, you can do: git config diff.wsErrorHighlight all See doc on git diff and on git config. For versions older than that, you can set the color.diff.whitespace config setting, e.g. with: git config color.diff.whitespace “red reverse” (I’m assuming that you already have color.diff or color.ui set to auto … Read more

Can I do a partial revert in GIT

You can revert the commit without creating a new one by adding the –no-commit option. This leaves all the reverted files in the staging area. From there, I’d perform a mixed reset (the default for reset) to un-stage the files, and add in the changes I really wanted. Then, commit, (you can add and commit … Read more