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.

3350 questions
237
votes
5 answers

How to delete the last n commits on Github and locally?

I'm trying to delete the last 2 commits from one of my GitHub repositories. I've tried as suggested here : git push -f origin HEAD^^:master. It seems that it works, as the last two commits are removed. Then I deleted them from my local repository…
Ivan Fernandez
  • 4,173
  • 5
  • 25
  • 30
231
votes
6 answers

Git commit in terminal opens VIM, but can't get back to terminal

Trying to learn GitHub at the moment and doing this Git essentials tutorial over at nettuts. I'm on the lesson about making commits. The teacher types git commit and it opens VIM as his editor (I'd also like to know how to make it open up in Sublime…
Leon Gaban
  • 36,509
  • 115
  • 332
  • 529
228
votes
5 answers

How to commit no change and new message?

How can I make a new commit and create a new message if no changes are made to files? Is this not possible since the commit's code (SHA ?) will be the same?
d-_-b
  • 21,536
  • 40
  • 150
  • 256
224
votes
8 answers

Mercurial: how to amend the last commit?

I'm looking for a counter-part of git commit --amend in Mercurial, i.e. a way to modify the commit which my working copy is linked to. I'm only interested in the last commit, not an arbitrary earlier commit. The requirements for this amend-procedure…
mstrap
  • 16,808
  • 10
  • 56
  • 86
220
votes
9 answers

Editing the git commit message in GitHub

Is there any way of online editing the commit message in GitHub.com, after submission? From the command line, one can do git commit --amend -m "New commit message" as correctly suggested in the following question: How to modify existing, unpushed…
PNS
  • 19,295
  • 32
  • 96
  • 143
207
votes
8 answers

Git: How to edit/reword a merge commit's message?

How do I edit or reword a merge commit's message? git commit --amend works if it's the last commit made (HEAD), but what if it comes before HEAD? git rebase -i HEAD~5 doesn't list the merge commits.
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
206
votes
2 answers

How to find commits by a specific user in Git?

Our project uses Git as the version control system and recently I needed to review someone's commits. How can I see a list of commits made by a specific user?
user285020
  • 2,913
  • 4
  • 22
  • 17
205
votes
9 answers

See "real" commit date / time in github (hour/day)

Is there a way to see the date of a commit in github, with day/hour precision? Older commits appear in a "human readable" format, such as "2 years ago" instead of showing the actual date. If it's not possible to see the actual date on github, is…
loopbackbee
  • 21,962
  • 10
  • 62
  • 97
189
votes
14 answers

How to add multiple files to Git at the same time

This will be my first git use. I have added new files ( a lot ) to the folder/project ( git local repository). I went through online tutorials and forums and see i can do git commit -a So I go to the base folder of the repository and do a sudo git…
kishore .
  • 2,123
  • 2
  • 16
  • 12
177
votes
8 answers

How to git ignore ipython notebook checkpoints anywhere in repository

This is mostly a git question. I want to commit my ipython notebooks but gitignore the checkpoints. The repo has multiple folders which each have ipython notebooks, therefore just ignoring a single directory does not solve it. I want to keep adding…
sapo_cosmico
  • 6,274
  • 12
  • 45
  • 58
176
votes
7 answers

Combining Multiple Commits Into One Prior To Push

This question pertains not only to how to accomplish this task, but to whether doing so is good or bad practice with Git. Consider that locally I do most work on the main branch, but I have created a topical branch I will call feature_branch. In the…
Todd Hopkinson
  • 6,803
  • 5
  • 32
  • 34
162
votes
10 answers

GIT commit as different user without email / or only email

I'm trying to commit some changes as a different user, but i do not have a valid email address, following command is not working for me: git commit --author="john doe" -m "some fix" fatal: No existing author found with 'john doe' I have the same…
Willem D'Haeseleer
  • 19,661
  • 9
  • 66
  • 99
158
votes
7 answers

git - Your branch is ahead of 'origin/master' by 1 commit

I am newbie in git and I am working on git. I added some files in git : git add git add then I wanted to push that for review, but mistakenly I did git commit so the files which I have changed don't go for reviews. Now if I…
sam
  • 18,509
  • 24
  • 83
  • 116
156
votes
9 answers

Git: add vs push vs commit

What is the difference between git add, push and commit? Just a little confused coming from SVN, where "update" will 'add' stuff, and commit does a "push" and will 'add' as well There are all different functions within git. Hoping for some…
CQM
  • 42,592
  • 75
  • 224
  • 366
154
votes
10 answers

Git commit with no commit message

How can I commit changes without specifying commit message? Why is it required by default?
Nik
  • 1,605
  • 2
  • 11
  • 4