Is it possible to cherry-pick a commit from another git repository?
2022-05-13
Question I'm working with a git repository that needs a commit from another git repository that knows nothing of the first. Typically I would cherry-pick using the HEAD@{x} in the reflog, but because this .git knows nothing of this reflog entry (different physical directory), how can I cherry-pick this, or can I? I'm using git-svn. My first branch is using git-svn of the trunk of a Subversion repo, and the next branch is using git-svn on a Subversion branch.…
Update git commit author date when amending
2022-05-13
Question I found myself amending my commits quite often. I don't stash so much because I tend to forget I did so, especially when I want to save what I did before I leave or before a weekend, so I do a "draft" commit. Only thing is, when I amend the commit, it is still set to the original author date. Is there a (simple) way to update it when amending?…
How much of a git sha is *generally* considered necessary to uniquely identify a change in a given codebase?
2022-05-11
Question If you're going to build, say, a directory structure where a directory is named for a commit in a Git repository, and you want it to be short enough to make your eyes not bleed, but long enough that the chance of it colliding would be negligible, how much of the SHA substring is generally required? Let's say I want to uniquely identify this change: https://github.com/wycats/handlebars.js/commit/e62999f9ece7d9218b9768a908f8df9c11d7e920 I can use as little as the first four characters: https://github.…
Git: How to update/checkout a single file from remote origin master?
2022-05-08
Question The scenario: I make some changes in a single file locally and run git add, git commit and git push The file is pushed to the remote origin master repository I have another local repository that is deployed via Capistrano with the "remote_cache" method from that remote repository Now I don't want to deploy the whole application but just update/checkout that single file. Is this somehow possible with git? I wasn't able to find anything that would work nor was I able to figure it out.…
How to revert initial git commit?
2022-05-08
Question I commit to a git repository for the first time; I then regret the commit and want to revert it. I try # git reset --hard HEAD~1 I get this message: fatal: ambiguous argument 'HEAD~1': unknown revision or path not in the working tree. This commit is the first commit of the repository. Any idea how to undo git's initial commit? Answer You just need to delete the branch you are on.…
How do I make a branch point at a specific commit? [duplicate]
2022-05-07
Question This question already has answers here: </div> Move branch pointer to different commit without checkout (11 answers) Closed 3 years ago. In Git, I understand that a branch is a pointer to a commit. How do I make a specific branch point to a specific commit? Say I want to make master point at 1258f0d0aae..., how do I do that? Answer You can make master point at 1258f0d0aae this way:…
How to add a local repo and treat it as a remote repo
2022-05-07
Question I'm trying to make a local repo act as a remote with the name bak for another local repo on my PC, using the following: git remote add /home/sas/dev/apps/smx/repo/bak/ontologybackend/.git bak which gives this error: fatal: '/home/sas/dev/apps/smx/repo/bak/ontologybackend/.git' is not a valid remote name I'm trying to sync two local repos, with one configured as a remote named bak for the other, and then issuing git pull bak. What is the best way to do it?…