git error: failed to push some refs to remote
2023-04-22
Question I can't push now, though I could do it yesterday. When I use git push origin master, I get an error: $ git remote -v origin https://github.com/REDACTED.git (fetch) origin https://github.com/REDACTED.git (push) $ git push origin master Username for ‘https://github.com’: REDACTED Password for ‘https://REDACTED@github.com’: To https://github.com/REDACTED.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to ‘https://github.com/REDACTED.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart.…
Exclude file from "git diff"
2023-04-21
Question I am trying to exclude a file (db/irrelevant.php) from a Git diff. I have tried putting a file in the db subdirectory called .gitattributes with the line irrelevant.php -diff and I have also tried creating a file called .git/info/attributes containing db/irrelevant.php. In all cases, the db/irrelevant.php file is included in the diff as a Git binary patch. What I want is for the changes to that file to be ignore by the diff command.…
git: 'credential-cache' is not a git command
2023-04-21
Question I followed these instructions to the letter, including the part about password caching. It seems like the instructions are wrong, because every time I git push origin master I get this error: git: 'credential-cache' is not a git command. See 'get --help'. ... at which point I am forced to enter my username and password. After doing so, I am presented with the same error message again, followed by the output from git push.…
Could not open a connection to your authentication agent
2023-04-20
Question I am running into this error of: $ git push heroku master Warning: Permanently added the RSA host key for IP address '50.19.85.132' to the list of known hosts. ! Your key with fingerprint b7:fd:15:25:02:8e:5f:06:4f:1c:af:f3:f0:c3:c2:65 is not authorized to access bitstarter. I tried to add the keys and I get this error below: $ ssh-add ~/.ssh/id_rsa.pub Could not open a connection to your authentication agent. Answer Did You Start ssh-agent?…
How to permanently remove few commits from remote branch
2023-04-20
Question I know that's rewriting of history which is bad yada yada. But how to permanently remove few commits from remote branch? Answer You git reset --hard your local branch to remove changes from working tree and index, and you git push --force (or git push --force-with-lease) your revised local branch to the remote. (other solution here, involving deleting the remote branch, and re-pushing it) This SO answer illustrates the danger of such a command, especially if people depends on the remote history for their own local repos.…
Git - push current branch shortcut
2023-04-17
Question Is there a shortcut to tell Git to push the current tracking branch to origin? Note: I know that I can change the default push behavior, but I am looking for an ad-hoc solution that does not change the default behavior. For example, suppose I am on branch feature/123-sandbox-tests I would be using git push origin feature/123-sandbox-tests which is tedious. I am looking for a shortcut, something like git push origin current # <- example, not working where git knows that current is feature/123-sandbox-tests.…
How do I change the author and committer name/email for multiple commits?
2023-04-17
Question How do I change the author for a range of commits? Answer NOTE: This answer changes SHA1s, so take care when using it on a branch that has already been pushed. If you only want to fix the spelling of a name or update an old email, Git lets you do this without rewriting history using .mailmap. See my other answer. Using Rebase First, if you haven't already done so, you will likely want to fix your name in git-config:…