This post is mainly a reminder of some errors I have encountered with Git. Writting things down may help me avoid recurrent errors :)
GIT push: permission denied (public key)
- Happened when I wanted to
git push. - stackoverflow
- Need to set up the SSH key and add it to Github (or wherever your
remoteis). - I was surprised when finding out that I didn’t do it on my laptop!
src refspec master does not match any.
- Happened when I wanted to
git push. When creating mygithub.iorepo, I didn’t follow the process of forking the template and then modifying. I cloned the original repo, modified it and then wanted to push to theoriginto the emptygithub.iorepo that I created. At first it didn’t work because theoriginstill points to the original repo which of course I cannot write to. Then I changed theoriginbygit remote set-urland it gave me this error. I thought it was because of not forking the repo, so I followed the recommended path again. But this error still persisted. - stackoverflow
- Turned out that the forked repo did not have the
masterbranch, only agh-pagesbranch. I need to specify the branch name…
Miscellaneous
- show changes on a file before commit, before/after add
git diff fileshows diff of a file from the previous commit.git diff --cached fileafter add - show refs:
git show-ref - git clone submodules
git clone --recurse-submodules -j8 git://github.com/foo/bar.git - update submodules: commit in submodule, push in submodule, commit in main repo, push in main repo. (not validated yet)
git push <remote_name> --delete <branch_name>deletes a remote branch.git branch -d/-D <branch_name>deletes a local branch.-Dforces the delete.git cherry-pick <commit>applys the changes introduced bycommiton top of the current branch. I used that a lot. Probably it is very bad…git config --global alias.co checkoutset a global git shorthand.
(Background image credit: video)