游戏 Game 配置文件存档同步到Git,你敢想?
伊谢尔伦
伊谢尔伦 2017-05-02 09:44:06
0
2
624
标题党,其实我是想请教一下Git的相关问题

大致需求


我有一个游戏文件夹,大致目录结构如下。

游戏目录 XxxGames/

  • 文件夹 Plugin

    • 一些文件

  • 文件夹 Data

    • 一些文件

  • 文件夹 Save

    • 一些存档

  • 根目录下一些文件.exe/.log等

我的操作


  1. 在XxxGames下 $ git init

  2. 然后 $ git remote add coding http://url.git

  3. 在目录下新建了一个 .gitignore 文件排除了一些文件

  4. $ git add .

  5. $ git commit -m "first commit"

  6. $ git push coding master

  7. 推送成功了,但是发现有些目录和文件不需要同步

  8. 于是又修改 .gitignore 再次排除不需要的目录和文件

  9. 再 $ git add . 和 commit 的时候为什么不排除我刚更新的文件只是更新了.gitignore

详细问题


  1. 本地已经有的文件夹(项目),要同步到git具体是个什么步骤。

  2. push过以后再修改u.gitignore 再add再commit 为什么不排除我刚修改的排除

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(2)
小葫芦

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已经生效"
过去多啦不再A梦

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!