Like version files ONLY locally with git

I have a project with two branches foo and baar . In this project, I have the database1.properties and database1.properties configuration files, where the database properties are stored, for example, the schema name and password of the schema. When I work on the foo branch, the schema name is foo and the password is foo, and when I work on the baar schema name it is baar and the password is baar. How to tell git that these property files are only for my local system and should not be migrated to the original repo? I am using egit as well as tortoiseGit.

+6
source share
2 answers

With one branch, you cannot interfere with selected files.

When the branch is pressed, all commits will be pressed on the remote control.

As a workaround, you can have your changes (local-specific) in another branch ( foo-local , bar-local , etc.), and whenever you want to use these changes on the local system, use git merge local-branch --no-commit --no-ff or a similar command to merge into the actual branch (this will not result in merging your local specific changes into the remote tracking branch). Once you are done, you can undo these changes (however, these changes will always be present in the local branch and can be applied to the actual branch at any time).

+3
source

Path 1 - Constant rebase

Suppose there are 3 branches:

  • master for public
  • boo for private
  • baar for private

Something like that:

2 branches

You developed something on the master branch, then reinstall the foo and baar branch on master. You need (1) Place an order foo , (2) Restore foo to master , (3) Place an order baar , (4) Restore baar to master, then it will be as follows:

enter image description here

Note : repeat these steps over and over.

Method 2 - Merge

Assume the same 3 branches.

Checkout foo and merge master into foo :

enter image description here

Do something on the baar branch, and finally you get:

enter image description here

After you have developed some of the master, complete these steps again and get:

enter image description here

Path 3 - Submodule

The above two methods are a little dangerous if you push all the branches to the remote one. This method is more complicated, you need to know how to use the submodule, but I like it more. :)

(1) Prepare a data repo for a private database, you can check the branch between foo / baar .

enter image description here

enter image description here

(2) Prepare another regular / simple repo as a container, something like this:

enter image description here

enter image description here

(3) Then add this repo as a submodule to this repo:

enter image description here

You will receive them after committing:

enter image description here

enter image description here

(4) Again, add a public repo named test here as a submodule:

enter image description here

enter image description here

Currently, you can develop test repo in this repo and check any branch of the data repo on the other side.

Note 1 : You must configure the path correctly.

Note 2 : if you do not like the submodule, you can just use the folder as a container and then put two repos in it.

Method 4 - Merge Without Fixation or Squash

As this answer (by @Royal Pinto) said, I am showing the TortoiseGit operation here.

enter image description here

enter image description here

Note: personal data has been placed in the index file. For the next commit command to pass it to the repo.

+1
source

All Articles