Permission denied (publickey) when deploying heroku code. fatal: The remote end hung up unexpectedly
2022-05-22
Question I'm attempting to deploy my code to heroku with the following command line: git push heroku master but get the following error: Permission denied (publickey). fatal: The remote end hung up unexpectedly I have already uploaded my public SSH key, but it still comes up with this error. Answer You have to upload your public key to Heroku: heroku keys:add ~/.ssh/id_rsa.pub If you don't have a public key, Heroku will prompt you to add one automatically which works seamlessly.…
git-checkout older revision of a file under a new name
2022-05-21
Question I have the file "main.cpp" open in my editor. I want to see the previous revision of "main.cpp" in the editor too. The way I do it now is like this. close "main.cpp" in the editor prompt> mv main.cpp tmp prompt> git checkout HEAD^ main.cpp prompt> mv main.cpp old_main.cpp prompt> mv tmp main.cpp prompt> open “main.cpp” and “old_main.cpp” in the editor Can it be simplified, so I don't have to close "…
How to git-svn clone the last n revisions from a Subversion repository?
2022-05-21
Question Problem How do you create a shallow copy with git-svn from a Subversion repository, e.g. how do you pull only the last three revisions? The git clone command can get the last n revisions from a Git repository if you use the option --depth, i.e. you get a shallow copy of the repository. Example: git clone --depth 3 git://some/repo myshallowcopyrepo Is there a similar option for git-svn? My discoveries so far…
How to merge a specific commit in Git
2022-05-21
Question I have forked a branch from a repository in GitHub and committed something specific to me. Now I found the original repository had a good feature which was at HEAD. I want to merge it only without previous commits. What should I do? I know how to merge all commits: git branch -b a-good-feature git pull repository master git checkout master git merge a-good-feature git commit -a git push Answer git cherry-pick should be your answer here.…
How can I remove an entry in global configuration with git config?
2022-05-20
Question I ran a global configuration command in git to exclude certain files using a .gitignore_global file: git config --global core.excludesfile ~/.gitignore_global Is there a way to undo the creation of this setting globally? Answer I'm not sure what you mean by "undo" the change. You can remove the core.excludesfile setting like this: git config --global --unset core.excludesfile And of course you can simply edit the config file: git config --global --edit .…
Git submodule head 'reference is not a tree' error
2022-05-19
Question I have a project with a submodule that is pointing to an invalid commit: the submodule commit remained local and when I try to fetch it from another repo I get: $ git submodule update fatal: reference is not a tree: 2d7cfbd09fc96c04c4c41148d44ed7778add6b43 Unable to checkout '2d7cfbd09fc96c04c4c41148d44ed7778add6b43' in submodule path 'mysubmodule' I know what the submodule HEAD should be, is there any way I can change this locally, without pushing from the repo that does have commit 2d7cfbd09fc96c04c4c41148d44ed7778add6b43 ?…
How can I pull/push from multiple remote locations?
2022-05-19
Question The short: is there a way to have a git repo push to and pull from a list of remote repos (rather than a single "origin")? The long: I often have a situation when I'm developing an app in multiple computers, with different connectivity – say a laptop while on transit, a computer "A" while I'm in a certain location, and another computer "B" while on another. Also, the laptop might have connectivity with only either "…