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
25854
votes
105 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 do I undo those commits from the local repository?
Hamza Yerlikaya
  • 49,047
  • 44
  • 147
  • 241
7650
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
  • 136,234
  • 13
  • 47
  • 54
3997
votes
137 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
  • 40,334
  • 3
  • 19
  • 16
3521
votes
29 answers

Commit only part of a file's changes 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
  • 57,041
  • 28
  • 76
  • 106
2981
votes
27 answers

How to change the commit author for a single commit?

I want to change the author of one specific commit in the history. It's not the latest commit. Related: How do I change the author and committer name/email for multiple commits?
MicTech
  • 42,457
  • 14
  • 62
  • 79
2258
votes
27 answers

How to list unpushed Git commits (local but not on origin)

How can I view any local commits I've made, that haven't yet been pushed to the remote repository? Occasionally, git status will print out that my branch is X commits ahead of origin/master, but not always. Is this a bug with my install of Git, or…
Josh Buhler
  • 26,878
  • 9
  • 29
  • 45
2186
votes
37 answers

Remove file from latest commit

How do I remove a file from the latest commit?
Lolly
  • 34,250
  • 42
  • 115
  • 150
2089
votes
22 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
  • 20,909
  • 3
  • 13
  • 4
2004
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
  • 74,396
  • 19
  • 43
  • 46
1384
votes
32 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
  • 43,508
  • 23
  • 86
  • 119
1357
votes
12 answers

Remove a git commit which has not been pushed

I did a git commit but I have not pushed it to the repository yet. So when I do git status, I get '# Your branch is ahead of 'master' by 1 commit. So if I want to roll back my top commit, can I just do: git reset --hard…
hap497
  • 154,439
  • 43
  • 83
  • 99
1224
votes
14 answers

How can I 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
  • 30,529
  • 42
  • 121
  • 191
1064
votes
23 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
  • 16,523
  • 10
  • 42
  • 62
1009
votes
7 answers

Skip Git commit hooks

I'm looking at a Git hook which looks for print statements in Python code. If a print statement is found, it prevents the Git commit. I want to override this hook and I was told that there is a command to do so. I haven't been able to find it. …
Ben
  • 15,010
  • 11
  • 58
  • 90
1001
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
  • 29,229
  • 42
  • 124
  • 179
1
2 3
99 100