Can't push to GitHub because of large file which I already deleted
2022-09-18
Question Currently I have Empty GitHub repo SSH server repo (main) Local Repo SSH server repo was the most up-to-date repo (production site) so I did a Git clone from there to local. I then tried to do a git push to GitHub. Everything went OK but then it said something about filename.gz being too large for GitHub. I didn't need this file so I ran several Git commands to get rid of it from Git cache then pushed back to SSH server.…
Break a previous commit into multiple commits
2022-09-17
Question Without creating a branch and doing a bunch of funky work on a new branch, is it possible to break a single commit into a few different commits after it's been committed to the local repository? Answer 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.…
Git: can't undo local changes (error: path ... is unmerged)
2022-09-17
Question I have following working tree state $ git status foo/bar.txt # On branch master # Unmerged paths: # (use "git reset HEAD <file>..." to unstage) # (use "git add/rm <file>..." as appropriate to mark resolution) # # deleted by us: foo/bar.txt # no changes added to commit (use "git add" and/or "git commit -a") File foo/bar.txt is there and I want to get it to the "unchanged state" again (similar to 'svn revert'):…
How do I rename a Git repository?
2022-09-17
Question git mv renames a file or directory in a repository. How do I rename the Git repository itself? Answer There are various possible interpretations of what is meant by renaming a Git repository: the displayed name, the repository directory, or the remote repository name. Each requires different steps to rename. Displayed Name Rename the displayed name (for example, shown by gitweb): Edit .git/description to contain the repository's name. Save the file.…
Download Github pull request as unified diff
2022-09-16
Question How can I download the changes contained in a Github pull request as a unified diff? Answer To view a commit as a diff/patch file, just add .diff or .patch to the end of the URL, for example: https://github.com/weppos/whois/pull/90 https://github.com/weppos/whois/pull/90.diff https://github.com/weppos/whois/pull/90.patch
How do I move an existing Git submodule within a Git repository?
2022-09-16
Question I would like to change the directory name of a Git submodule in my Git superproject. Lets suppose I have the following entry in my .gitmodules file: [submodule ".emacs.d/vimpulse"] path = .emacs.d/vimpulse url = git://gitorious.org/vimpulse/vimpulse.git What do I have to type to move the .emacs.d/vimpulse directory to .emacs.d/vendor/vimpulse without deleting it first (explained here and here) and then re-adding it. Does Git really need the whole path in the submodule tag…
Remove a file from a Git repository without deleting it from the local filesystem
2022-09-16
Question I want to remove a file from my repository. git rm file_to_remove.txt will remove the file from the repository, but it will also remove the file from the local file system. How do I remove this file from the repo without deleting my local copy of the file? Answer The git rm documentation states: When --cached is given, the staged content has to match either the tip of the branch or the file on disk, allowing the file to be removed from just the index.…