How can I commit files with git?

前端 未结 9 1717
慢半拍i
慢半拍i 2020-12-07 12:21

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..

#          


        
相关标签:
9条回答
  • 2020-12-07 12:27

    The command for commiting all changed files:

    git commit -a -m 'My commit comments'
    

    -a = all edited files

    -m = following string is a comment.

    This will commit to your local drives / folders repo. If you want to push your changes to a git server / remotely hosted server, after the above command type:

    git push
    

    GitHub's cheat sheet is quite handy.

    0 讨论(0)
  • 2020-12-07 12:28

    Git uses "the index" to prepare commits. You can add and remove changes from the index before you commit (in your paste you already have deleted ~10 files with git rm). When the index looks like you want it, run git commit.

    Usually this will fire up vim. To insert text hit i, <esc> goes back to normal mode, hit ZZ to save and quit (ZQ to quit without saving). voilà, there's your commit

    0 讨论(0)
  • 2020-12-07 12:28

    It looks like all of the edits are already a part of the index. So to commit just use the commit command

    git commit -m "My Commit Message"
    

    Looking at your messages though my instinct says that you probably don't want the cache files to be included in your depot. Especially if it something that is built on the fly when running your program. If so then you should add the following line to your .gitignore file

    httpdocs/newsite/manifest/cache/*
    
    0 讨论(0)
  • 2020-12-07 12:30

    It sounds as if the only problem here is that the default editor that is launched is vi or vim, with which you're not familiar. (As quick tip, to exit that editor without saving changes, hit Esc a few times and then type :, q, ! and Enter.)

    There are several ways to set up your default editor, and you haven't indicated which operating system you're using, so it's difficult to recommend one in particular. I'd suggest using:

     git config --global core.editor "name-of-your-editor"
    

    ... which sets a global git preference for a particular editor. Alternatively you can set the $EDITOR environment variable.

    0 讨论(0)
  • 2020-12-07 12:32

    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"
    
    0 讨论(0)
  • 2020-12-07 12:41

    in standart Vi editor in this situation you should

    1. press Esc
    2. type ":wq" (without quotes)
    3. Press Enter
    0 讨论(0)
提交回复
热议问题