Hard reset of a single file

To reset both the working copy of my-file.txt and its state in the Git index to that of HEAD: git checkout HEAD — my-file.txt — means “treat every argument after this point as a filename”. More details in this answer. Thanks to VonC for pointing this out.

How do I remove a directory from a Git repository?

Remove directory from Git and local Checkout ‘master’ with both directories: git rm -r one-of-the-directories // This deletes from filesystem git commit . -m “Remove duplicated directory” git push origin <your-git-branch> (typically ‘master’, but not always) Remove directory from Git but NOT local To remove this directory from Git but not delete it entirely from … Read more

How to specify the private SSH-key to use when executing shell command on Git?

None of these solutions worked for me. Instead, I elaborate on @Martin v. Löwis ‘s mention of setting a config file for SSH. SSH will look for the user’s ~/.ssh/config file. I have mine setup as: Host gitserv Hostname remote.server.com IdentityFile ~/.ssh/id_rsa.github IdentitiesOnly yes # see NOTES below And I add a remote git repository: … Read more

How do I migrate an SVN repository with history to a new Git repository?

Create a users file (i.e. users.txt) for mapping SVN users to Git: user1 = First Last Name <email@address.com> user2 = First Last Name <email@address.com> … You can use this one-liner to build a template from your existing SVN repository: svn log -q | awk -F ‘|’ ‘/^r/ {gsub(/ /, “”, $2); sub(” $”, “”, $2); … Read more

Break a previous commit into multiple commits

git rebase -i will do it. First, start with a clean working directory: git status should show no pending modifications, deletions, or additions. Now, you have to decide which commit(s) you want to split. A) Splitting the most recent commit To split apart your most recent commit, first: $ git reset HEAD~ Now commit the … Read more

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