Questions tagged [commit]

Questions about committing a transaction or "unit of work" to a database, application or version control system.

The usual context of this tag is application and/or database transactions but it is also applicable to version control software.

Within the application/database context, a commit means that all state changes made during the current transaction are made permanent.

Within the context of version control software, the "unit of work" being committed is the total change being written to the central store. Usually, "commit" refers to the command used to perform this action (e.g., git commit or svn commit).

The nature of different source control systems lead to different styles of committing. However, there are generally two agreed upon practices:

  1. Commit only single units of work (fixing a single bug, adding a single feature, etc.) - this makes history easier to walk through. Conversely, avoid making large, sweeping commits, which pollute history.

  2. Commit messages should be fairly concise and clear. This makes understanding who has done what (typically done using a command like blame) easier. This practice is an extension of the first, because single units of work are easier to write clear commit messages for.

Beyond these two guidelines, the majority of workflow is determined by how distributed a version control system is. Generally speaking, what goes into a centralized system like Subversion is much more strictly controlled because it is harder to undo; most commits in a centralized system involve running a project's entire test suite.

Distributed systems like Git tend to be less strict about what is committed, because it is the author who chooses when to push commits to a remote repository and can run test suites before choosing to push their changes; also, any mistakes can be reversed by editing private history.

3018 questions
3192
votes
107 answers

Message 'src refspec master does not match any' when pushing commits in Git

I clone my repository with: git clone ssh://xxxxx/xx.git But after I change some files and add and commit them, I want to push them to the server: git add xxx.php git commit -m "TEST" git push origin master But the error I get back is: error: src…
sinoohe
  • 32,258
  • 3
  • 16
  • 16
1496
votes
12 answers

How to undo "git commit --amend" done instead of "git commit"

I accidentally amended my previous commit. The commit should have been separate to keep history of the changes I made to a particular file. Is there a way to undo that last commit? If I do something like git reset --hard HEAD^, the first commit also…
Jesper Rønn-Jensen
  • 91,561
  • 40
  • 112
  • 147
1190
votes
15 answers

How to revert multiple git commits?

I have a git repository that looks like this: A <- B <- C <- D <- HEAD I want the head of the branch to point to A, i.e. I want B, C, D, and HEAD to disappear and I want head to be synonymous with A. It sounds like I can either try to rebase…
Bill
  • 38,492
  • 24
  • 114
  • 205
1132
votes
12 answers

Changing git commit message after push (given that no one pulled from remote)

I have made a git commit and subsequent push. I would like to change the commit message. If I understand correctly, this is not advisable because someone might have pulled from the remote repository before I make such changes. What if I know that no…
K_U
  • 11,952
  • 8
  • 22
  • 28
899
votes
8 answers

How can I push a specific commit to a remote, and not previous commits?

I have made several commits on different files, but so far I would like to push to my remote repository only a specific commit. Is that possible?
Robert23
  • 8,991
  • 3
  • 13
  • 3
895
votes
17 answers

How can I list all commits that changed a specific file?

Is there a way to list all commits that changed a specific file?
Daniel
  • 9,285
  • 3
  • 16
  • 15
844
votes
24 answers

How can one change the timestamp of an old commit in Git?

The answers to How to modify existing, unpushed commits? describe a way to amend previous commit messages that haven't yet been pushed upstream. The new messages inherit the timestamps of the original commits. This seems logical, but is there a…
Dhskjlkakdh
  • 8,941
  • 5
  • 20
  • 16
748
votes
6 answers

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

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?
Sridhar Sarnobat
  • 19,595
  • 12
  • 74
  • 93
743
votes
3 answers

How to commit my current changes to a different branch in Git

Sometimes it happens that I make some changes in my working directory, and I realize that these changes should be committed in a branch different to the current one. This usually happens when I want to try out new things or do some testing and I…
Auron
  • 11,904
  • 14
  • 42
  • 53
732
votes
9 answers

git add only modified changes and ignore untracked files

I ran "git status" and listed below are some files that were modified/or under the heading "changes not staged for commit". It also listed some untracked files that I want to ignore (I have a ".gitignore" file in these directories). I want to put…
Steve
  • 10,251
  • 13
  • 49
  • 63
626
votes
1 answer

How do I create a new Git branch from an old commit?

Possible Duplicate / a more recent/less clear question Branch from a previous commit using Git I have a Git branch called jzbranch and have an old commit id: a9c146a09505837ec03b. How do I create a new branch, justin, from the information listed…
JZ.
  • 19,005
  • 31
  • 110
  • 185
567
votes
10 answers

How to edit log message already committed in Subversion?

Is there a way to edit the log message of a certain revision in Subversion? I accidentally wrote the wrong filename in my commit message which could be confusing later. I've seen How do I edit an incorrect commit message in Git?, but the solution to…
Paige Ruten
  • 157,734
  • 36
  • 172
  • 191
553
votes
4 answers

How can I reference a commit in an issue comment on GitHub?

I find a lot of answers on how to reference a GitHub issue in a git commit (using the #xxx notation). I'd like to reference a commit in my comment, generating a link to the commit details page?
LodeRunner
  • 6,625
  • 3
  • 18
  • 22
419
votes
14 answers

Git blame -- prior commits?

Is it possible to see who edited a specific line before the commit reported by git blame, like a history of commits for a given line? For example, I run the following (on the superb uncrustify project): $ git blame -L10,+1 src/options.cpp ^fe25b6d…
Sedate Alien
  • 10,572
  • 6
  • 35
  • 57
408
votes
5 answers

How to move certain commits to be based on another branch in git?

The situation: master is at X quickfix1 is at X + 2 commits Such that: o-o-X (master HEAD) \ q1a--q1b (quickfix1 HEAD) Then I started working on quickfix2, but by accident took quickfix1 as the source branch to copy, not the master.…
Alex Yarmula
  • 9,942
  • 5
  • 29
  • 31
1
2 3
99 100