天道酬勤,学无止境

git

How to get SHA of file for specific Git commit?

Is there a way to get SHA of file for specific Git commit? It's possible with 2 commands: retrieving file git show COMMIT_VERSION:myfile.txt > ~/tmp/myfile.txt calculating SHA git hash-object ./tmp/myfile.txt But, maybe there's specific command in Git that does exactly that?

2021-06-15 18:06:25    分类:问答    git   commit   sha

Git filter-branch gave me two sets of commits

I needed to remove a file from my commit history. I followed Github's instructions for removing sensitive data: $ git filter-branch --force --index-filter \ 'git rm --cached --ignore-unmatch <myfile>' \ --prune-empty --tag-name-filter cat -- --all ...but I must have done something wrong, because now I have a bunch of duplicate commits. One set of commits still has my file; the other doesn't. Other than that, they're identical. How can I delete all of the commits that still contain my file?

2021-06-15 17:53:36    分类:问答    git

Visual Studio 2013 remove deleted git branches

I am having this problem where in VS2013 when I create a new branch from origin, the dropdown with the source branches lists ALL branches ever created. This includes branches that have long been deleted from both the local repo and the remote/origin repo. How do I remove the deleted branches?

2021-06-15 17:46:20    分类:问答    git   visual-studio   visual-studio-2013

git fast-export format and spaces

I'm writing a fast-export/fast-import for Plastic SCM but I'm having issues dealing with directories and files containing spaces in their names. For instance, a git fast-export of something like: git mv "new directory" "second directory" ends up being exported as: D new directory/hello.c M 100644 :1 second directory/hello.c Instead of a "move" (R) operation. Same happens with a file with spaces in the name. Is there a way to handle it correctly? Does it mean that Git can't handle renames on paths with spaces? Edited with a real example below: I've something like this on a commit: R src/samples

2021-06-15 17:45:17    分类:问答    git   plasticscm

Is it possible to accept user input as part of a remote git post-receive hook?

I've got a post-receive hook that deploys our master branch whenever we push master. I'd like to make the deployment optional; the hook asks for simple Y/N response to achieve this; bash pseudo code below: echo "Should I deploy this code now? Enter Y/N" read deploy_code case ${deploy_code} in "Y") do_a_deploy ;; "N") exit ;; *) # ask the question again if not Y or N ;; esac Because of the way the post-receive hook gets its arguments on stdin the read line doesn't pause for input from the user, and the script loops round and round trying to get a Y/N answer. I thought that specifically

2021-06-15 17:38:50    分类:问答    git   bash   ssh   hook   tty

Why does git delete ignored files under `directory/*` but not under `directory/`

As mentioned in this post To put it another way, if you have the following in your .gitignore: /my-ignored-directory/* Then you’re screwed – after a git stash save -u, my-ignored-file.txt will be gone (and sorry, it’s not in the stash you just created either). Break out the undelete packages and hope for the best. Alternatively, if you have the following in your .gitignore: /my-ignored-directory Then you’re golden – no worries, kick back, relax, my-ignored-file.txt will stay exactly where it was prior to the git stash save -u. Why is this difference? I'm also wondering if no files will be

2021-06-15 17:35:48    分类:问答    git

Git inserted many <<<<< error messages into my sourcecode

I'm very new to using Git, so many things escape me. Yesterday I tried to do a git revert operation which failed, and it generated some error about merging or stuff. I found a workaround this, by cloning my repository and then using $ git reset --hard SHA1_HASH to get back to a previous commit. Unfortunately, now my code is peppered with lots of additional stuff like <<<<<<<<<<<< HEAD //some stuff ======= //other stuff >>>>>>>>>>>> parent of 1ae3953... Removed duplicate folders How do I remove this stuff? I'm having a really hard time going through all my files and deleting them by hand... Is

2021-06-15 17:20:57    分类:问答    git

Git: Only push private config file to test repository and not to github?

I have a Rails app with a config/my_private_data.yml file. I would like to push the entire app both to my test server and to github. However, when I push to the test server, I want to include the private file. When I push to github, I don't want to include the private file. What is the easiest way to go about this?

2021-06-15 16:33:57    分类:问答    git   github   config

401 Unauthorized error using NetBeans + Git on BitBucket

I have a local git repository. Recently I have added a remote repository from bitbucket, and have pushed my branch there without any problem by: git push bitbucket (since I've configured username and password in https url). But when I try to push, using NetBeans, I always get 401 Unauthorized, when I choose from configured remote repos list and when I try to enter the remote repo details manually. I have the most recent version of NetBeans and Git plugin. Thanks for any help in advance.

2021-06-15 16:16:24    分类:问答    git   netbeans   push   bitbucket   unauthorized

How to I switch to a git branch that ignores files without deleting these files?

I have branch master that ignores .idea in its .gitignore. From that, I created branch noIgnore that has no .gitignore. I found that checkout master deletes .idea. That's not the behavior I want. I want to keep .idea, just not track it, not on master. How do I do that?

2021-06-15 15:10:42    分类:问答    git   gitignore