0

I'm new to GIT and Branches. I've two problems with GIT

  1. There are two branches Dev and Master, whenever we've done any modifications in Dev we are syncing them with Master branch(if required). Some time we are getting error while doing commit the changes in Dev, by using pull option we've resolved the error. While doing pull, GIT automatically merging my modifications into master branch. While GIT is configured with Jenkins the changes are going to Production without any approval from business.

  2. Some times, other team peoples just copying other HTML pages themselves directly into prod folder(Which is also a part of GIT). So, whenever we merge the code with dev, the local files are replacing prod files.

Could you please anyone help on this. I'm struggling a lot since 1 week.

Thanks in advance!!

Chanikya
  • 476
  • 1
  • 8
  • 22
  • Stop allowing multiple developers from introducing files with the same name in the same location within your project. – Tim Biegeleisen Oct 22 '19 at 10:23
  • What exactly is `prod` folder and why do you need it? E.g. why do you have `prod` folder in `Dev` and `Master`? – sbat Oct 22 '19 at 10:29
  • As a best practice, use branch protection rules under **Settings** > **Branches** to prevent people from directly merging their changes into the `master`, `prod` or any other critical branch. Developers must create their own feature branches from these branches and when they want to merge, create pull requests to be reviewed by code owners. See https://github.community/t5/How-to-use-Git-and-GitHub/GitHub-Top-10-Best-Practices/td-p/14228. – Dibakar Aditya Oct 22 '19 at 10:37
  • If you only want selected commits on `dev` to be added to `master` and thus into production you may need to look at a flow based on cherry picking commits. But seems like you would be better with everyone working on topic/feature branches and having an approval process via pull requests to include into `dev`. – Richard Oct 22 '19 at 10:41
  • @DibakarAditya, If i provide the rules to branch, will local files(unmodified) push to prod server or Dev server ? Or else is there any way to skip a specific folder to don't commit? – Chanikya Oct 22 '19 at 10:50
  • @Chanikya To prevent a file or directory from being committed, you can create a `.gitignore` file at the root of your repository and add an entry/regex to ignore them as needed. See https://stackoverflow.com/questions/1470572/ignoring-any-bin-directory-on-a-git-project. Then commit this file. However, note that this will ignore the directory from being committed from any machine where the repository is cloned. – Dibakar Aditya Oct 22 '19 at 12:38
  • In addition, if you want only the modified files to be committed and ignore the new untracked files in your local repository, use the single command `git commit -am ` instead of `git add .; git commit -m `. – Dibakar Aditya Oct 22 '19 at 12:47
  • @DibakarAditya, where to enter those commands in Visual Studio? – Chanikya Oct 22 '19 at 13:26
  • I apparently missed that you are using the VS interface. You can just run these commands on the terminal (View > Terminal) or externally using Gitbash/command prompt. – Dibakar Aditya Oct 22 '19 at 13:33

0 Answers0