How to add multiple files to Git at the same time

后端 未结 10 623
半阙折子戏
半阙折子戏 2021-01-29 18:12

This will be my first git use. I have added new files ( a lot ) to the folder/project ( git local repository).

I went through online tutorials and forums and see i can do

相关标签:
10条回答
  • 2021-01-29 18:16

    Use the git add command, followed by a list of space-separated filenames. Include paths if in other directories, e.g. directory-name/file-name.

    git add file-1 file-2 file-3
    
    0 讨论(0)
  • 2021-01-29 18:17

    You can also select multiple files like this

    git add folder/subfolder/*
    

    This will add all the files in the specified subfolder. Very useful when you edit a bunch of files but you just want to commit some of them...

    0 讨论(0)
  • 2021-01-29 18:20

    0 讨论(0)
  • 2021-01-29 18:24

    If you want to add multiple files in a given folder you can split them using {,}. This is awesome for not repeating long paths, e.g.

    git add long/path/{file1,file2,...,filen}
    

    Beware not to put spaces between the ,.

    0 讨论(0)
  • 2021-01-29 18:24

    Simply use single quotations around each file name to ensure any with spaces work as expected

    git add 'file1' 'file2' 'file3' 
    
    0 讨论(0)
  • 2021-01-29 18:26

    When you change files or add a new ones in repository you first must stage them.

    git add <file>
    

    or if you want to stage all

    git add .
    

    By doing this you are telling to git what files you want in your next commit. Then you do:

    git commit -m 'your message here'
    

    You use

    git push origin master
    

    where origin is the remote repository branch and master is your local repository branch.

    0 讨论(0)
提交回复
热议问题