git-commit

Remove files from Git commit

余生颓废 提交于 2019-11-26 12:33:40
I am using Git and I have committed few files using git commit -a Later, I found that a file had mistakenly been added to the commit. How can I remove a file from the last commit? juzzlin I think other answers here are wrong, because this is a question of moving the mistakenly committed files back to the staging area from the previous commit, without cancelling the changes done to them. This can be done like Paritosh Singh suggested: git reset --soft HEAD^ or git reset --soft HEAD~1 Then reset the unwanted files in order to leave them out from the commit: git reset HEAD path/to/unwanted_file

How can I change the default comments in the git commit message?

落爺英雄遲暮 提交于 2019-11-26 12:21:51
Is it possible to modify the commented part of the default git commit message? I want to add a bit more 'context' information for my users. # Please enter the commit message for your changes. # (Comment lines starting with '#' will not be included) # Explicit paths specified without -i nor -o; assuming --only paths... # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: test.txt # weiqure You can use git hooks for that. Before the person who wants to commit the changes is shown the commit message, the prepare-commit-msg script is run. You

Git: what is a dangling commit/blob and where do they come from?

二次信任 提交于 2019-11-26 12:02:13
问题 I\'m looking for the basic info on dangling commits & blobs. My repo seems fine. But I ran git fsck for the first time to see what it did and I have a long list of \'dangling blobs\' and a single \'dangling commit\'. What are these things? Where did they come from? Do they indicate anything unusual (good or bad) about the state of my repo? 回答1: During the course of working with your git repository, you may end up backing out of operations, and making other moves that cause intermediary blobs,

How to fix committing to the wrong Git branch?

删除回忆录丶 提交于 2019-11-26 11:43:01
问题 I just made a perfectly good commit to the wrong branch. How do I undo the last commit in my master branch and then take those same changes and get them into my upgrade branch? 回答1: If you haven't yet pushed your changes, you can also do a soft reset: git reset --soft HEAD^ This will revert the commit, but put the committed changes back into your index. Assuming the branches are relatively up-to-date with regard to each other, git will let you do a checkout into the other branch, whereupon

Git commit that doesn&#39;t override original authors in git blame

▼魔方 西西 提交于 2019-11-26 10:47:28
问题 I\'ve used a perl script to modify all tab characters in a php git repository and changed them all to 4 spaces. $ find -iname \\*.php -exec perl -pi -e \"s/\\t/ /g\" {} \\ I can commit this change with git commit , but it will mark me as the author of all changed lines inside git blame after this commit is made. Is there any way to commit this massive change that doesn\'t mark me as the author of the changed lines, but retains the original author? That\'s a lot of history we don\'t really

How do I commit only some files?

一世执手 提交于 2019-11-26 10:05:43
问题 I have two projects. One is the \"official\" project and the second is a light modification (some files added). I created new branch and I put new files to them. But in during development some files common to both branches is changed. How do I commit only these files? 回答1: I suppose you want to commit the changes to one branch and then make those changes visible in the other branch. In git you should have no changes on top of HEAD when changing branches. You commit only the changed files by:

How to amend a commit without changing commit message (reusing the previous one)?

拥有回忆 提交于 2019-11-26 10:05:14
问题 Is there a way to amend a commit without vi (or your $EDITOR ) popping up with the option to modify your commit message, but simply reusing the previous message? 回答1: Since git 1.7.9 version you can also use git commit --amend --no-edit to get your result. Note that this will not include metadata from the other commit such as the timestamp which may or may not be important to you. 回答2: git commit -C HEAD --amend will do what you want. The -C option takes the metadata from another commit. 回答3:

Removing multiple files from a Git repo that have already been deleted from disk

纵饮孤独 提交于 2019-11-26 09:49:13
问题 I have a Git repo that I have deleted four files from using rm ( not git rm ), and my Git status looks like this: # deleted: file1.txt # deleted: file2.txt # deleted: file3.txt # deleted: file4.txt How do I remove these files from Git without having to manually go through and add each file like this: git rm file1 file2 file3 file4 Ideally, I\'m looking for something that works in the same way that git add . does, if that\'s possible. 回答1: For Git 1.x $ git add -u This tells git to

git: Your branch is ahead by X commits

久未见 提交于 2019-11-26 08:52:09
问题 How does this actually come about? I am working in one repo by myself at the moment, so this is my workflow: Change files Commit Repeat 1-2 until satisfied Push to master Then when I do a git status it tells me that my branch is ahead by X commits (presumably the same number of commits that I have made). Is it because when you push the code it doesn\'t actually update your locally cached files (in the .git folders)? git pull seems to \'fix\' this strange message, but I am still curious why it

What is the Sign Off feature in Git for?

依然范特西╮ 提交于 2019-11-26 08:39:32
问题 What\'s the point of the Sign Off feature in Git? git commit --signoff When should I use it, if at all? 回答1: Sign-off is a requirement for getting patches into the Linux kernel and a few other projects, but most projects don't actually use it. It was introduced in the wake of the SCO lawsuit, (and other accusations of copyright infringement from SCO, most of which they never actually took to court), as a Developers Certificate of Origin. It is used to say that you certify that you have