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
183
votes
4 answers

Differences between Commit, Commit and Push, Commit and Sync

I'm using visual studio 2013, and I'm faced with 3 options for when I commit my C# code. I need an explanation of the differences between each of the options with regards to what happens to my local repo vs. the GitHub repo. Option 1 says…
Alfred Waligo
  • 2,809
  • 3
  • 18
  • 26
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
166
votes
6 answers

How to reference the initial commit?

I've got a script that needs to reference the initial commit in a repository. git has the special reference HEAD, but doesn't have the corresponding TAIL. I cannot find anything in git help rev-parse that would seem to help me. Here's what I'd…
Bryan Larsen
  • 9,468
  • 8
  • 56
  • 46
151
votes
4 answers

Purging file from Git repo failed, unable to create new backup

I tried to remove a file from my remote repo by running: git filter-branch --index-filter 'git rm --cached --ignore-unmatch Rakefile' HEAD But Git complains that Cannot create new backup. A previous backup already exists in refs/original/ Force…
Cardin
  • 5,148
  • 5
  • 36
  • 37
149
votes
3 answers

How do I reword the very first git commit message?

I have a working tree containing 3 commmits: ➜ ~myproject git:(master) git log commit a99cce8240495de29254b5df8745e41815db5a75 Author: My Name Date: Thu Aug 16 00:59:05 2012 +0200 .gitignore edits commit…
Henrik
  • 2,421
  • 4
  • 25
  • 33
142
votes
5 answers

How to find out in which commit a particular code was added?

I want to find out in which commit did I add the code given below: if (getListView().getChildCount() == 0) getActivity().findViewById(android.R.id.empty).setVisibility(View.VISIBLE); How do I achieve this?
Harshal Kshatriya
  • 5,630
  • 11
  • 44
  • 60
135
votes
2 answers

git commit --amend without asking for message

From time to time I find myself commit-amending using the same message. Typically, I do: Add my changes to staging area. Do git commit --amend. Wait for the text editor to open. Save and close it (without changing the message). There is anyway to…
talles
  • 14,356
  • 8
  • 45
  • 58
131
votes
13 answers

Undo git reset --hard with uncommitted files in the staging area

I am trying to recover my work. I stupidly did git reset --hard, but before that I've done only get add . and didn't do git commit. Please help! Here is my log: MacBookPro:api user$ git status # On branch master # Changes to be committed: # (use…
eistrati
  • 2,314
  • 6
  • 26
  • 35
128
votes
3 answers

Git - Can we recover deleted commits?

I am surprised, I couldn't find the answer to this on SO. Can we recover/restore deleted commits in git? For example, this is what I did: # Remove the last commit from my local branch $ git reset --hard HEAD~1 # Force push the delete $ git push…
Atri
  • 5,511
  • 5
  • 30
  • 40
126
votes
10 answers

How can I recover from an erronous git push -f origin master?

I just committed the wrong source to my project using --force option. Is it possible to revert? I understand that all previous branches have been overwritten using -f option, so I may have screwed up my previous revisions.
David van Dugteren
  • 3,879
  • 9
  • 33
  • 48
125
votes
7 answers

Git commit -a "untracked files"?

When I do a git commit -a, I am seeing the following: # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch better_tag_show # Changes to be…
xjq233p_1
  • 7,810
  • 11
  • 61
  • 107
124
votes
13 answers

How can I fix git commit error "Waiting for your editor to close the file..." with VS Code?

I'm trying just git commit and Git is giving this message: hint: Waiting for your editor to close the file... /c/Users/AGT/AppData/Local/Programs/Microsoft VS Code/bin/code: line 28: /Code.exe: No such file or directory error: There was a…
AGT
  • 1,343
  • 2
  • 8
  • 10
122
votes
3 answers

git add . vs git commit -a

What's the difference between: git add . git commit -a Should I be doing both, or is that redundant?
Yarin
  • 173,523
  • 149
  • 402
  • 512
116
votes
10 answers

Using IntelliJ to amend git commit message

Can one amend a git commit message using IntelliJ, or should one resort to command line? How can this be done please?
James Raitsev
  • 92,517
  • 154
  • 335
  • 470
108
votes
5 answers

How to change past commit to include a missed file?

I have committed a change and forgot to add a file to the change set. After other commits, I realized the file is now missing from a HEAD^4 commit. How do I rewrite a previous commit to include the missing file?
kolrie
  • 12,562
  • 14
  • 64
  • 98