The current git workflow my development team uses and most other teams are following is to use the master branch as the default and BUILD and DEPLOY aka CI/CD branch. However, only the TEAM LEAD has the authorization rights to PULL into master. So developers create all branches from master and perform the git add [filename] or .
and git commit -m 'User Story XYZ'
, then git push
to remote and create a PULL REQUEST.
However, in this situation we have to ensure all developers have their own local configuration files and ensure they are not deployed. Better yet what happens if they were originally added and commited to the master branch? Hopefully this guide will help you.
The files in question are the .config files, which should not be ignored, but need to change per developer workstation.
WARNING --- YOU WILL HAVE ISSUES GOING BACK AND FORTH TO PREVIOUS BRANCHES THAT YOU CREATED BEFORE YOU PERFORM THESE STEPS
The key is to ensure you are on your master branch and run the following git commands.
git checkout master
git pull
git status
You want to ensure you have a clean working tree...
2 Steps - If the files you want to ignore have never been added to the GIT local repository
Add to the exclude file. If using windows open windows explorer and be sure to unhide hidden files and navigate to your repo location in windows we use:
C:\Users\USERNAME\source\repos\SolutionName\.git\info\exclude
(Note: The exclude file needs to be open with a text editor of your choice Notepad or Notepad++)
The run
git add
Add the files you need to ignore only as you do the .ignore file, but this is used for your personal developer workstation. Give the full path to the file.
C:/Users/USERNAME/Source/Repos/SolutionName/{filename}
IF YOU ALREADY HAVE FILES THAT HAVE BEEN ADDED AND COMMITTED AS SHOWN BELOW FOLLOW THESE STEPS
ADD THE FILES To ---
C:\Users\USERNAME\Source\repos\SolutionName\.git\info\exclude
Following the same format as above: (Note exclude is a file you need to open with NotePad or NotePad++)
C:/Users/USERNAME/Source/Repos/SolutionName/{filename}
git add
git committed -m 'Committing my files to GIT index'
HOWEVER, GO BACK TO GIT AND RUN THE FOLLOWING IF THE FILES HAVE BEEN ADDED AND COMMITED BEFORE
git update-index --skip-worktree
Reapeat as needed for the files you want to ignore.
Start branching and all should be good in the world. I will come back and provide an update based on this discovery work.
Happy GIT'ing........................
To validate you can run the following Git Command
git ls-files -i --exclude-from=C:/Users/USERNAME/source/repos/SolutionName