search

Home  >  Q&A  >  body text

Do you dare to think about synchronizing game configuration file archives to Git?

标题党,其实我是想请教一下Git的相关问题

Approximate requirements


I have a game folder, the approximate directory structure is as follows.

Game Directory XxxGames/

My operations


  1. Under XxxGames $ git init

  2. Then $ git remote add coding http://url.git

  3. Created a new .gitignore file in the directory to exclude some files

  4. $ git add .

  5. $ git commit -m "first commit"

  6. $ git push coding master

  7. The push was successful, but some directories and files did not need to be synchronized

  8. So I modified .gitignore to exclude unnecessary directories and files again

  9. When $ git add . and commit, why not exclude the file I just updated and just update .gitignore

Detailed questions


  1. What are the specific steps to synchronize an existing local folder (project) to git.

  2. After push, modify u.gitignore, then add and then commit. Why not exclude the exclusion I just modified?

伊谢尔伦伊谢尔伦2771 days ago662

reply all(2)I'll reply

  • 高洛峰

    高洛峰2017-05-02 09:46:06

    First of all, the first question, the specific steps are also very simple, roughly the following steps:

    • Initialize warehouse

    git init
    • Add gitignore file

    • Check the status of the files in the warehouse. Here you can see whether the files that should be ignored are ignored and whether the files that should be added can be seen

    git status -s
    • Add to staging area

    git add .
    • Submit

    git commit -m "commit message"
    • Add remote warehouse

    git remote add origin <url of remote repository>
    • Push to remote warehouse

    git push -u origin master

    The origin in the above command can be specified at will, it is just customary to write it like this.
    Then there is the second problem. This is because those files have been tracked before, and modifying .gitignore again will not take effect (this seems to be a known bug of git). The best way to solve this problem is: if you have just made some modifications, submit these modifications first, and then run the following command:

    git rm -r --cached .
    git add .
    git commit -m "gitignore已经生效"

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-02 09:46:06

    So I modified .gitignore to exclude unnecessary directories and files again

    You need to delete it first and then commit it. Next time you add a file, ignore will take effect

    reply
    0
  • Cancelreply