0

I have 2 folders in my project say APJ and EMEA and files can be committed from both the folders but I have a scenario where I want to trigger only APJ files or EMEA files.

I tried with only changes option but it didn't help. Changes:

- DB/APJ/**/*

For example, My commit contains 2 files, one from APJ folder and one from EMEA folder. I want files from APJ folder only. How do I filter my commit files?

 Commit : abcs123
 File1 :  DB/APJ/test.sql
 File2 : DB/EMEA/test2.sql

Is there a way to add some settings in the .yml file? The expected result is to get APJ files and EMEA files separately even when I commit them together.

cnom
  • 3,071
  • 4
  • 30
  • 60
Asma
  • 99
  • 9
  • What has this to do with `c#`? –  Jul 10 '19 at 09:13
  • I am using gitlab API with C# code to get commit details.. I was thinking is there a way to filter commit files at API level? – Asma Jul 10 '19 at 09:26
  • what exactly are you trying to achieve? to commit files from specific folder only? or to view committed files from specific folder only? it is not clear in your question. – cnom Jul 10 '19 at 09:33
  • To view specific files from commit. – Asma Jul 10 '19 at 09:53
  • To do this, you should create an application layer over the gitlab api. I do not see a valid reason for gitlab api to have it already available as an option. BTW what gitlab api endpoint are you using now to get the commit files? – cnom Jul 10 '19 at 10:44

3 Answers3

1

You could do it by adding files from the specific folder (APJ) before commit.

git add DB/APJ
git commit -m "my changed files in APJ"

See this post as well: Commit changes only in one directory in Git

cnom
  • 3,071
  • 4
  • 30
  • 60
  • But i dont have control over commit. User can commit files from any folder. I need to filter them based on the project path – Asma Jul 10 '19 at 09:27
  • the "user" is to decide what is staged (with git add command) before commit. so, the user is to take care what is added. – cnom Jul 10 '19 at 09:30
0

Only staged files can be committed.So you can do this by

git add DB/APJ/
git commit -m "files in DB/APJ are changed"

Moreover, if you want to ignore files from specific folder you can add those folders in git ignore.

  1. Create a file named .gitignore in your project's directory. (if it is not exists in your repository yet)
  2. To Ignore directories/Folders, just write the directory_name/folder_name/file_name into the file (with a slash appended):
 DB/APJ/

for more information check here

naib khan
  • 928
  • 9
  • 16
0

git show -m -1 --name-only --pretty=format: --stat --relative

By using above command we can filter commit files, It will only return the folder specific files If i am in APJ folder and execute this command then i will get only APJ folder files from the commit. Note that this commit can contain files from APJ and EMEA folders. Hope everyone is able to understand :)

Asma
  • 99
  • 9