Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Git commits changes for a warehouse implementation subdirectory separately

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

The project team has a requirement: at present, our online code is hosted by the git warehouse, and both the developer and the front-end need to modify the files in the js directory in the warehouse. In order to avoid conflicts, we want to separate the subdirectories in the warehouse so that the front-end engineers can submit them to the git warehouse. In the past, updates were made through ftp, and there will be a lot of problems. Changing this way will improve productivity.

Comparison of git and svn:

Svn is based on file-based centralized storage, Git is based on metadata-based distributed storage of file information, it will take all the information back to the local every time Clone, that is, equivalent to generating a clone version of the version library on your machine, since the local has a complete version library, there must be all permissions, so there is no way to control the permissions of subdirectories.

Achieve:

Git's support for sparse clone,sparse clone since 1.7.0 is also a workaround: first get all the object and other metadata information of repository, and then add a file called .git / info/sparse-checkout locally (that is, blacklist, whitelist, support rules, see the following specific operation commands) to control those directories and files of pull (similar to .gitignore files, all local concepts) Flexible implementation git only specifies subdirectories and files in the clone repository

Steps:

1. Create a directory locally to submit code

Mkdir test

two。 Initialize the warehouse

Git init

3. Pull the objects information of the remote warehouse

Git remote add-f origin git@code.aliyun.com:test/test.git

4. Turn on sparse clone

Git config core.sparsecheckout tr

Ue

5. Set the directory that requires pull * to represent all

Echo "develop" > > .git/info/sparse-checkoutecho "web/assets/*" > > .git/info/sparse-checkout

6. Pull remote warehouse

Git pull origin master

7. View

Ll assets/total 4drwxr-xr-x 1 Administrator 197121 0 July 10 10:51 css/drwxr-xr-x 1 Administrator 197121 July 10 10:51 img/drwxr-xr-x 1 Administrator 197121 0 July 10 10:51 js/drwxr-xr-x 1 Administrator 197121 0 July 10 10:51 lib/

8. Local test submission

Touch test.txtecho "this is a test" git add .git commit-m "test" git push origin masterCounting objects: 4, done.Delta compression using up to 4 threads.Compressing objects: 100% (3bytes 3), done.Writing objects: 100% (4 bytes 4), 331 bytes | 0 bytes/s, done.Total 4 (delta 2), reused 0 (delta 0) To code.aliyun.com:test8/test.git037b8ec..317b2a2 master-> master

Reference document: http://www.wfuyu.com/technology/25144.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report