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

1851 questions
24007
votes
98 answers

How do I undo the most recent local commits in Git?

I accidentally committed the wrong files to Git but didn't push the commit to the server yet. How can I undo those commits from the local repository? The only way seems to be to copy the edits in some kind of GUI text editor, then wipe the whole…
Hamza Yerlikaya
  • 48,189
  • 40
  • 139
  • 234
7656
votes
27 answers

How to modify existing, unpushed commit messages?

I wrote the wrong thing in a commit message. How can I change the message? The commit has not been pushed yet.
Laurie Young
  • 132,296
  • 13
  • 46
  • 54
3529
votes
116 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
  • 35,636
  • 3
  • 17
  • 16
3215
votes
26 answers

Commit only part of a file in Git

When I make changes to a file in Git, how can I commit only some of the changes? For example, how could I commit only 15 lines out of 30 lines that have been changed in a file?
freddiefujiwara
  • 52,799
  • 28
  • 73
  • 104
2584
votes
22 answers

How to change the commit author for one specific commit?

I want to change the author of one specific commit in the history. It's not the last commit. I know about this question - How do I change the author of a commit in git? But I am thinking about something, where I identify the commit by hash or…
MicTech
  • 38,157
  • 14
  • 59
  • 79
1957
votes
33 answers

Remove files from Git commit

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?
Lolly
  • 30,816
  • 39
  • 109
  • 142
1859
votes
21 answers

How can I remove a commit on GitHub?

I "accidentally" pushed a commit to GitHub. Is it possible to remove this commit? I want to revert my GitHub repository as it was before this commit.
hectorsq
  • 69,276
  • 19
  • 42
  • 46
1762
votes
17 answers

How do I commit case-sensitive only filename changes in Git?

I have changed a few files name by de-capitalize the first letter, as in Name.jpg to name.jpg. Git does not recognize this changes and I had to delete the files and upload them again. Is there a way that Git can be case-sensitive when checking for…
Gil Shulman
  • 17,639
  • 3
  • 11
  • 4
1357
votes
31 answers

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

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…
Codebeef
  • 42,480
  • 20
  • 84
  • 117
1174
votes
14 answers

How to revert uncommitted changes including files and folders?

Is there a git command to revert all uncommitted changes in a working tree and index and to also remove newly created files and folders?
MEM
  • 29,041
  • 40
  • 118
  • 191
961
votes
16 answers

What are the differences between "git commit" and "git push"?

In a Git tutorial I'm going through, git commit is used to store the changes you've made. What is git push used for then?
ben
  • 27,829
  • 41
  • 123
  • 175
946
votes
20 answers

How do I resolve git saying "Commit your changes or stash them before you can merge"?

I made some updates on my local machine, pushed them to a remote repository, and now I'm trying to pull the changes to the server and I get the message; error: Your local changes to the following files would be overwritten by…
Jo Sprague
  • 14,619
  • 10
  • 39
  • 59
875
votes
8 answers

Link to the issue number on GitHub within a commit message

Is it somehow possible to automatically have a link to GitHub issue number in the git commit message?
Mika Tuupola
  • 18,787
  • 5
  • 38
  • 45
853
votes
6 answers

How to cancel a local git commit?

My issue is I have changed a file e.g.: README, added a new line 'this for my testing line' and saved the file, then I issued the following commands: git status # On branch master # Changed but not updated: # (use "git add ..." to update…
Amal Kumar S
  • 14,725
  • 19
  • 53
  • 87
832
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
  • 21,632
  • 12
  • 79
  • 100
1
2 3
99 100