Questions tagged [git-commit]

git-commit - Record changes to the repository along with a log message.

Stores the current contents of the index in a new commit along with a log message from the user describing the changes.

Added from reference

2117 questions
403
votes
5 answers

Edit the root commit in Git?

There's ways to change the message from later commits: git commit --amend # for the most recent commit git rebase --interactive master~2 # but requires *parent* How can you change the commit message of the very first commit…
13ren
  • 11,887
  • 9
  • 47
  • 64
386
votes
8 answers

How do I commit only some files?

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…
Nips
  • 13,162
  • 23
  • 65
  • 103
325
votes
12 answers

What does "Changes not staged for commit" mean

I thought if you want to track the files you should git add [files you want to track] I don't know why I got the messages Changes not staged for commit. If those files were not staged, shouldn't git shows me those files were Untracked like…
newBike
  • 14,385
  • 29
  • 109
  • 192
312
votes
8 answers

How can I undo a `git commit` locally and on a remote after `git push`

I have performed git commit followed by a git push. How can I revert that change on both local and remote repositories? $ git log commit 364705c23011b0fc6a7ca2d80c86cef4a7c4db7ac8 Author: Michael Silver Date: Tue Jun 11…
michael
  • 106,540
  • 116
  • 246
  • 346
309
votes
4 answers

How to find the commit in which a given file was added?

Say I have a file foo.js that was committed some time ago. I would like to simply find the commit where this file was first added. After reading the answers and my own tinkering, this works for me git log --follow --diff-filter=A --find-renames=40%…
Zombo
  • 1
  • 62
  • 391
  • 407
299
votes
8 answers

How to amend several commits in Git to change author

I have made a series of commits in Git and I realise now that I forgot to set my user name and user email properties correctly (new machine). I have not yet pushed these commits to my repository, so how can I correct these commits before I do so…
pauldoo
  • 18,087
  • 20
  • 94
  • 116
293
votes
11 answers

How to remove the first commit in git?

I am curious about how to remove the first commit in git. What is the revision before committing any thing? Does this revision have a name or tag?
Weihang Jian
  • 7,826
  • 4
  • 44
  • 55
286
votes
7 answers

Vim for Windows - What do I type to save and exit from a file?

Using Windows XP I accidentally typed git commit -a instead of git commit -am "My commit message", and now I'm viewing my CMD prompt filled with the file version of my commit message ("Please enter the commit message for your..."). I've added my…
orokusaki
  • 55,146
  • 59
  • 179
  • 257
267
votes
8 answers

How to 'git commit' a single file/directory

I tried the following command: git commit path/to/my/file.ext -m 'my notes' And received an error in Git version 1.5.2.1: error: pathspec '-m' did not match any file(s) known to git. error: pathspec 'MY MESSAGE' did not match any file(s) known to…
doublejosh
  • 5,548
  • 4
  • 39
  • 45
267
votes
2 answers

How to undo the last commit in git

By mistake, I did git add . and git commit in the develop branch. But luckily, I did not do git push. So I wanted to revert it back to original state. I tried git reset --soft and git reset HEAD --hard but looks like I have messed it up. How do I…
chintan s
  • 6,170
  • 16
  • 53
  • 86
262
votes
14 answers

Why does 'git commit' not save my changes?

I did a git commit -m "message" like this: > git commit -m "save arezzo files" # On branch master # Changes not staged for commit: # (use "git add ..." to update what will be committed) # (use "git checkout -- ..." to discard changes…
arezzo
  • 2,915
  • 2
  • 15
  • 14
252
votes
5 answers

How to save a git commit message from windows cmd?

I run git from the command line. How does one save the commit message? I mean what keys should I press to go past this screen:
Jackson Publick
  • 2,545
  • 2
  • 13
  • 5
232
votes
5 answers

What is a dangling commit and a blob in a Git repository and where do they come from?

I'm looking for the basic information on dangling commits and blobs. My repository 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?…
doub1ejack
  • 10,627
  • 20
  • 66
  • 125
214
votes
4 answers

Remove commit from history

I entered a curseword in my code and I pushed the code on the master branch. I pushed a few more times after that so people do not pull the bad stuff, but I can still find the curseword in the commits history. I don't want to add the file to…
Serban Stoenescu
  • 3,136
  • 3
  • 22
  • 41
210
votes
8 answers

Git, see a list of comments of my last N commits

Is there a way to see a list of comments and time of my last N commits in Git? After looking on SO, the only relevant thing I have found is Git - get all commits and blobs they created, but it shows all commits from all users, and outputs a lot of…
Salvador Dali
  • 214,103
  • 147
  • 703
  • 753