git-commit

How to forbid git commit if there are untracked files?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 13:08:56
问题 Sometimes, it makes sense to forbid git commit when there are untracked files, because you should add them either to files to commit or gitignore. And an option like -f to force this commit is also necessary. So is there any option/plugin/etc to do that? Thank you very much. 回答1: You can add a pre-commit hook that exits with a non-zero value if you find untracked files (you could examine the output of git status --porcelain -u to determine their presence--look for lines beginning with "?").

Can git filter out certain lines before commit?

孤街浪徒 提交于 2019-12-22 10:28:57
问题 I have a repo on github that I am working out of and I often have comments on my .py files that starts with the " # TODO: " to keep a personal note of things to be done. # TODO: do this <code> I obviously do not want that to go in a commit. I want GitHub to search all the files when I am about to commit them and not include lines that start with # TODO: Does Git already do this? I know certain version control like perforce already have this feature. Any thoughts? 回答1: I want GitHub to search

How can I list all modified files by an author between a commit range but only with the last thing that happened to the file in Git?

梦想的初衷 提交于 2019-12-22 08:16:10
问题 The command: git log --oneline --name-status --author=$AUTHOR $COMMIT_RANGE | grep -vE '[a-fA-F0-9]{5} ' | sort | uniq | cat -n Returns a list of the files modified by an author between a range of commits with the status e.g. M for modified. 1 M a_file 2 M another_file 3 M file 4 D file How can I show only the last thing that happened to the file file , e.g. here it was deleted ( D )? I don't want to see the previous modifications to the file (i.e. the M ), only the last thing that happened

Prevent git from automatically generating user email if missing

我是研究僧i 提交于 2019-12-21 12:39:11
问题 Is there a way to globally configure git to not automatically generate user's email, if none is set and abort the commit instead? $ git commit -m "test" [master (root-commit) 71c3e2e] test Committer: unknown <my.user@my.very.own.hostname> Your name and email address were configured automatically based on your username and hostname. Please check that they are accurate. This can cause serious privacy leaks if the committer is not careful enough to check git warnings. 回答1: Set git config -

Git: how to repack all loose commits

空扰寡人 提交于 2019-12-21 12:17:29
问题 After using git gc and git repack (with various options) I still have 4825 loose commits in the folder .git/objects . I would like to have all of them in the pack file with the rest or in another pack file. I'm doing lots commit rewriting (amend + rebase) hence it's perfectly normal to have many unreachable commits. My .gitconfig contains these parameters to keep reflogs and unreachable commits for a long time. [gc] reflogExpire = 300 days reflogExpireUnreachable = 200 days pruneExpire = 90

How grep through your staged files prior to committing?

荒凉一梦 提交于 2019-12-21 07:59:09
问题 So prior to running git commit I often will run the following: git grep --cached -l -I "debugger" I thought it was similar to: git diff --cached (which will show you all the changes you are about to commit, ie. will show you the diff in your staged files). Unfortunately, I just found that the --cached option for git grep simply tells git to "only" look at everything in its index. So how can I run git grep and have it only grep through my staged files? (Yes, I know I could simply do git diff -

How can I skip commits in git?

好久不见. 提交于 2019-12-21 07:30:59
问题 I have some commits that I don't want in my project, but there's a commit based on them which I do want in it. This is my GitHub "Network" graph of the repository (ASCII, as I still cannot post images): []--[]--[_] | | | ------->| ---------->[·]--[·]--[*] (-> means a merge) I want to delete the changes made in the two [·] commits, and base the [*] one on the [_] one above. I've tryed merging and rebasing, but they apply the changes of the unwanted commits. Is it possible? Sorry if I'm not

How to find the branch from commit id

此生再无相见时 提交于 2019-12-20 17:27:34
问题 So, I am trying to find branch name in which a given commit was made. ( c853d8cf3ae34dae9866b874b96c6529515d7e90 ) I have the parent id and commit id referenced on the git issue. How can I find that given commit id was pushed in ' x ' branch? 回答1: On GitHub specifically, you now can see the branch a given commit is part of. The blog post "Branch and Tag Labels For Commit Pages" details: If the commit is not on the default branch, the indicator will show the branches which contain the commit.

Commit to git after switching to workspace and adding CocoaPods in Xcode?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 17:17:11
问题 I've just added CocoaPods to my current project in Xcode 5. Of course, CocoaPods created a workspace and I've launched the workspace in Xcode. I see both my project and the Pods project in the workspace. My project has been under source control (local git + remote Bitbucket repository) since day one. Now I want to commit and add the Pod stuff but I think that my repo is too deep in the workspace--when I try to commit (and I've tried various commits to get the Pod stuff to take) it always

How do I see a commit's path through git history, or “how it got in the current branch”?

我是研究僧i 提交于 2019-12-20 14:57:09
问题 I'm looking in the commit history using gitk and git log and I'm trying to see how a specific commit arrived in a certain branch. I can see the commits in the history, so I know they are there. What I want to understand is how they got merged (they were supposed to remain on their own branch). This is a very large project and there are hundreds of commits between the commit in question and the current state of the branch, so I cannot clearly decipher through the limited DAG in gitk , and the