How do I make git use the editor of my choice for editing commit messages?

Setting the default editor for Git Pick one: Set core.editor in your Git config: git config –global core.editor “vim” Set the GIT_EDITOR environment variable: export GIT_EDITOR=vim Setting the default editor for all programs Set the standardized VISUAL and EDITOR environment variables*: export VISUAL=vim export EDITOR=”$VISUAL” NOTE: Setting both is not necessarily needed, but some programs … Read more

Git refusing to merge unrelated histories on rebase

You can use –allow-unrelated-histories to force the merge to happen. The reason behind this is that default behavior has changed since Git 2.9: “git merge” used to allow merging two branches that have no common base by default, which led to a brand new history of an existing project created and then get pulled by … Read more

Commit only part of a file in Git

You can use: git add –patch <filename> or for short: git add -p <filename> Git will break down your file into what it thinks are sensible “hunks” (portions of the file). It will then prompt you with this question: Stage this hunk [y,n,q,a,d,/,j,J,g,s,e,?]? Here is a description of each option: y stage this hunk for … Read more

How do I list all the files in a commit?

Preferred Way (because it’s a plumbing command; meant to be programmatic): $ git diff-tree –no-commit-id –name-only -r bd61ad98 index.html javascript/application.js javascript/ie6.js Another Way (less preferred for scripts, because it’s a porcelain command; meant to be user-facing) $ git show –pretty=”” –name-only bd61ad98 index.html javascript/application.js javascript/ie6.js The –no-commit-id suppresses the commit ID output. The –pretty argument … Read more

How do I create a remote Git branch?

First, create a new local branch and check it out: git checkout -b <branch-name> The remote branch is automatically created when you push it to the remote server: git push <remote-name> <branch-name> <remote-name> is typically origin, which is the name which git gives to the remote you cloned from. Your colleagues may then simply pull … Read more

Remove a file from a Git repository without deleting it from the local filesystem

The git rm documentation states: When –cached is given, the staged content has to match either the tip of the branch or the file on disk, allowing the file to be removed from just the index. So, for a single file: git rm –cached file_to_remove.txt and for a single directory: git rm –cached -r directory_to_remove

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)