I ran into a merge conflict. How do I abort the merge?

Since your pull was unsuccessful then HEAD (not HEAD^) is the last “valid” commit on your branch: git reset –hard HEAD The other piece you want is to let their changes over-ride your changes. Older versions of git allowed you to use the “theirs” merge strategy: git pull –strategy=theirs remote_branch But this has since been … Read more

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

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