To launch a diff with BC3, use the command “git difftool” or “git difftool foofile.txt”

Line endings

If you use git on windows like me, it’s better to configure it to “commit as-is, checkout as-is”.

git config --global core.autocrlf false

Pull behaviour

By default Git will merge remote changes with your local changes when pulling. This can result in an ugly commit graph that makes it difficult to track changes. Rebasing on the other hand results in a single commit line graph. Rebasing long-lived branches is not recommended.

The guidance is that when pulling; when you’re only making changes on the master branch (or any long-lived remote branch) always use rebase. If you’re working on a long-lived branch merge should be used when pulling in changes from the original branch or merging back to that branch.

git pull --rebase

github

Generate a new ssh key on your machine. Go for default file name and type in your password.

Caching your credential

If you have to type in your username and password to push your change to github, your fingres and wrists will suffer. You can cache your credential for a certain period.

I cached it for 5 hours. If you want an hour, use 3600.

git config --global credential.helper 'cache --timeout=18000'

ignore ssl certificate error

when you commit to your company githup repository that doesn’t have signed certificate, unfortunately, you get an error. You can get around it by turning off the warning.

git config – –global http.sslVerify false

Git commit against tag with no branch

I honestly panicked. I wasn’t aware that the working directory was attached to any branch. I added and committed my changes (which took an hour of toil). Then it wasn’t in any branch. I checked out to master. All the changes seemed to be lost!

The saviour was git reflog. You can find your commit SHA1, and checkout with it.

Share this:

Like this:

Related

Post navigation

2 thoughts on “git tips”

I read a lot of interesting posts here. Probably
you spend a lot of time writing, i know how to save you a lot
of time, there is an online tool that creates readable,
SEO friendly posts in seconds, just search in google – laranitas free content source