Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I commit files with git?

Tags:

git

None of the tutorials will help!
They all do that thing where they just assume I know what to do..

Currently, my terminal window starts with..

# Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch master # Changes to be committed: #   (use "git reset HEAD <file>..." to unstage) # #       deleted:    httpdocs/newsite/manifest/cache/0a432970ba6491fe65dad60b012e5c95_louloumay2011en-1-4dea3186b7f7b.jpg #       deleted:    httpdocs/newsite/manifest/cache/0a61b5d7a9e97da78fe602e1ad41edb6_5-4dec7c3d57c80.jpg #       deleted:    httpdocs/newsite/manifest/cache/0afb6a7716a85d0de46cdd03bb30f75f_fifa_panorama_full_page-01_thu-4dea3d1a0e0f5.jpg #       deleted:    httpdocs/newsite/manifest/cache/0b3bc9be76a5d3e1e36af4b8dcf98658_free2-4df0e2e08761f.jpg #       deleted:    httpdocs/newsite/manifest/cache/0b6342913b8e599fac76da452af98ec5_si-feb-2009-1-4dea3d1abcb61.jpg #       deleted:    httpdocs/newsite/manifest/cache/0b9ddc587340f7744e03c4b2dafacf7f_lou-lou-winter-2009-cover-4dea3d1a9b1a0.jpg #       deleted:    httpdocs/newsite/manifest/cache/0bf64ff8fc22720b3da20d0730fa6a04_chatelaine-dec-2009-4dea3d18daa30.jpg #       deleted:    httpdocs/newsite/manifest/cache/0bf664e03eb0a2255b69b02aed85add0_summumfeb2011-2-4dea3188766aa.jpg 

but there's no way to know how to do what they say to do here..
http://learn.github.com/p/normal.html

All it says is

We simply type our commit message and exit the editor.

What does that mean?!
Just because you write the word simply doesn't mean it is simple..

When I start to type it does wierd stuff, says "recording" or "inserting" and there are about 300 files, and it wants me to replace every line with a message?!?

Help !

I would use their handy Mac application for this, but if it's over 20 files or so, it freezes up !
What's up with that??

like image 522
Kirk Strobeck Avatar asked Aug 16 '11 15:08

Kirk Strobeck


People also ask

Which git command is used to commit files?

The "commit" command is used to save your changes to the local repository. Note that you have to explicitly tell Git which changes you want to include in a commit before running the "git commit" command. This means that a file won't be automatically included in the next commit just because it was changed.

Can I add files to a commit?

Thus after making any changes to the working tree, and before running the commit command, you must use the add command to add any new or modified files to the index. This command can be performed multiple times before a commit.

How do I commit to a repository?

Commit the files staged in your local repository by writing a commit message. You can create a commit message by git commit -m 'your message' , which adds the change to the local repository.


1 Answers

When you run git commit with no arguments, it will open your default editor to allow you to type a commit message. Saving the file and quitting the editor will make the commit.

It looks like your default editor is Vi or Vim. The reason "weird stuff" happens when you type is that Vi doesn't start in insert mode - you have to hit i on your keyboard first! If you don't want that, you can change it to something simpler, for example:

git config --global core.editor nano 

Then you'll load the Nano editor (assuming it's installed!) when you commit, which is much more intuitive for users who've not used a modal editor such as Vi.

That text you see on your screen is just to remind you what you're about to commit. The lines are preceded by # which means they're comments, i.e. Git ignores those lines when you save your commit message. You don't need to type a message per file - just enter some text at the top of the editor's buffer.

To bypass the editor, you can provide a commit message as an argument, e.g.

git commit -m "Added foo to the bar" 
like image 107
Ben James Avatar answered Oct 01 '22 11:10

Ben James