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

1699 questions
22674
votes
92 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?
Hamza Yerlikaya
  • 47,689
  • 37
  • 135
  • 231
7659
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
  • 129,506
  • 13
  • 44
  • 54
3007
votes
25 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
  • 49,933
  • 28
  • 71
  • 102
2399
votes
21 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
  • 36,117
  • 14
  • 58
  • 79
1831
votes
32 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
  • 28,770
  • 36
  • 103
  • 140
1782
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
  • 66,366
  • 19
  • 41
  • 46
1580
votes
16 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
  • 15,819
  • 3
  • 10
  • 4
1339
votes
30 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
  • 41,810
  • 20
  • 83
  • 116
1131
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
  • 27,721
  • 40
  • 115
  • 190
939
votes
15 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
  • 26,837
  • 40
  • 121
  • 174
869
votes
18 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
  • 13,523
  • 9
  • 37
  • 57
819
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,021
  • 5
  • 36
  • 45
807
votes
6 answers

How to cancel a local git commit

My issue is I have changed a file eg: 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 what…
Amal Kumar S
  • 14,139
  • 19
  • 51
  • 83
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
741
votes
18 answers

Make the current commit the only (initial) commit in a Git repository?

I currently have a local Git repository, which I push to a Github repository. The local repository has ~10 commits, and the Github repository is a synchronised duplicate of this. What I'd like to do is remove ALL the version history from the local…
kaese
  • 8,759
  • 8
  • 25
  • 34
1
2 3
99 100