How can I push a specific commit to a remote, and not previous commits?

To push up through a given commit, you can write: git push <remotename> <commit SHA>:<remotebranchname> provided <remotebranchname> already exists on the remote. (If it doesn’t, you can use git push <remotename> <commit SHA>:refs/heads/<remotebranchname> to autocreate it.) If you want to push a commit without pushing previous commits, you should first use git rebase -i to … Read more

Force “git push” to overwrite remote files

You should be able to force your local revision to the remote repo by using git push -f <remote> <branch> (e.g. git push -f origin master). Leaving off <remote> and <branch> will force push all local branches that have set –set-upstream. Just be warned, if other people are sharing this repository their revision history will … Read more

How can I calculate the number of lines changed between two commits in Git?

You want the –stat option of git diff, or if you’re looking to parse this in a script, the –numstat option. git diff –stat <commit-ish> <commit-ish> –stat produces the human-readable output you’re used to seeing after merges; –numstat produces a nice table layout that scripts can easily interpret. I somehow missed that you were looking … Read more

When should I use git pull –rebase?

I would like to provide a different perspective on what “git pull –rebase” actually means, because it seems to get lost sometimes. If you’ve ever used Subversion (or CVS), you may be used to the behavior of “svn update”. If you have changes to commit and the commit fails because changes have been made upstream, … Read more

Getting Git to work with a proxy server – fails with “Request timed out”

Command to use: git config –global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080 change proxyuser to your proxy user change proxypwd to your proxy password change proxy.server.com to the URL of your proxy server change 8080 to the proxy port configured on your proxy server Note that this works for both http and https repos. If you decide at any … Read more

How do I resolve git saying “Commit your changes or stash them before you can merge”?

You can’t merge with local modifications. Git protects you from losing potentially important changes. You have three options: Commit the change using git commit -m “My message” Stash it. Stashing acts as a stack, where you can push changes, and you pop them in reverse order. To stash, type git stash Do the merge, and … Read more

How to remove files from git staging area?

You can unstage files from the index using git reset HEAD — path/to/file Just like git add, you can unstage files recursively by directory and so forth, so to unstage everything at once, run this from the root directory of your repository: git reset HEAD — . Also, for future reference, the output of git … Read more

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