Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

Tuesday, February 21, 2023

How to detect changes by using Git

In various scenarios, you need to know what files were modified by a developer in your feature or main branch. Knowing which files were modified, you can determine which modules were impacted.

For example, you have a test suite that can take hours to run, and now you are running it in your deployment pipeline on each file change. The benefit of such an approach is that you can guarantee the quality of your product and ensure that your code change doesn't break existing functionality. Still, it hurts your productivity and the possibility of delivering new features quickly.

A solution for this problem could be to run only tests associated with a specific module. Git can help here. You can use the git diff command to get changes.

The first command will produce a diff between two commits:

git diff --name-only <commit>..<commit>

The second command will find diff from their common ancestor.

git diff --name-only <commit>...<commit>

New Version


If you want to get files modified in a new version, run this command:

git diff --name-only v1.0.0..HEAD

The result should look like this:

readme.md
src/package1/config.json
src/package2/config.json

Feature branch


If you want to get files modified in a branch feature, run this command:

git diff --name-only master...HEAD

The result should look like this:

src/package3/config.json

References

Saturday, December 8, 2012

Create your Own Git Server on Azure Cloud

I wrote a blog post 'Create your Own Git Server on Azure Cloud'. This blog post can be found here.

Saturday, January 22, 2011

How to ignore files in Git

If you have files which you don't want to commit to repository, you can add entries to .gitignore file and these files won't be tracked any more.

You can add entry to .gitignore file with echo command:

echo csharp/Presentation/Presentation.suo >> .gitignore

If .gitignore file is not presented in your root directory of the project, you must create it.

The .gitignore file should be in your repository, so that changes to it can be merged and so on.

Friday, December 24, 2010

Initialize Git central repository

To create and initialize git repository on the server you must complete a few steps.

Create repository and a new group then add all the relevant users to that group and give the group ownership of the repository.

To init git repository on the server you must execute this command:

git init --bare --shared example.git

The shared option sets permissions on the everything in the repository to group writers.