I have an iOS that app that I need to deploy to several clients. Each clients has a few small changes in the app (images, provisioning files, app name, etc). 95% of the app is the same for all clients.
I don't want to maintain several git repositories (one for each client). I would rather have the once, with branches for each customer.
I'm new to this branching thing and need to know if this can be achieved.
I plan to create the master branch with generic images/configs/etc.
Create a branch for each client
Update each branch with the customers images/configs/etc
Then when I make a change I will make it to the master. Then pull the changes from the master to each branch. How can I stop the images, configs, etc from being overridden when I pull from master. Can I define certain files which can be ignored when I do this for each branch?
Is there a better way of managing what I need to do?
You should pull master and then rebase your branches on top of it.
See "Git: How to rebase many branches (with the same base commit) at once?" for a concrete example.
For extra security, you can add a merge driver "keepMine" associated for your files, and declare that merge driver in a .gitattributes file present in each of your branches.
See "How do I tell git to always select my local version for conflicted merges on a specific file?".
That will change the SHA1 of your client branches, and you will have to force push them to the client repo, but since said clients aren't actively modifying files on their side, it isn't a problem.
Related
Github has the option to allow a PR to be squashed when merged ("Squash and Merge")
Is there anyway I can configure the branch so it only allows the "Squash and Merge" option?
My scenario is this
we have a develop branch, that feature requests are pushed to
sometimes developers will forget to choose "Squash and Merge" and will commit their feature branch, with 10-20 tiny commits to the develop branch.
These changes eventually get merged to master, and feature history becomes hard to read
I have looked in hooks in branch protection rules, but didn't see any such option
Unfortunately the option to change what type of PR merge is available on Github is set on a per repo basis. Since PRs are a github thing, not a git thing, I can't think of a way that you'd be able to do anything with githooks either.
I don't see a great option for your workflow as long as you require the intermediate develop branch that eventually gets merged into master. Workflows that have multiple layers of PRs get messy on Github. The one real option would be that you require squash to merge on Github PRs and then the regular merge from develop to master happens outside a PR (could be local on a machine or via a Github action potentially).
But, your best option if this is really a big problem may be to modify your workflow. One common workflow would be that master is the development branch. Then when it is time for a release a release branch or tag, depending on your needs, is created from master. The you will have no issue turning on the repo wide requirement for squashing.
I have a project on github with two branches (dev and master), where code was in sync prior to adding some new features to dev. For a few months, I've been adding new features on the dev branch, which consisted of changes/updates to existing files, deleting some files, and creating new files, all on the dev branch. Everything is working great on the dev branch and now it's time to apply these changes to the master branch.
Since there are a lot of changes, I am trying to see all the differences visually between the dev and master branches, so I can apply the specific changes from dev to master without missing anything. I don't want to override master with dev, as there are some master specific files, so just the new things in dev should be applied to master, but I want to do it where I can see the compared files visually to ensure everything is looking right.
Any idea how to accomplish this?
Create a new branch from develop named release/may6. This way, you can commit changes to release/may6 without actually impacting your master branch.
Commit any master-specific differences to release/may6 and use the GitHub compare UI to see the differences between your working release/may6 branch and master:
https://github.com/orgname/reponame/compare/master...release/may6
Once you are satisfied that this view shows the correct master-only differences between release/may6 and master, simply create a Pull Request from that same compare UI which merges release/may6 into master.
Me and my friend are two days into using Git now but we still lack the know-how to use it properly and utilize its full power though it is a tremendous step in the right direction, compared to using Facebook messages to sending and syncing files. We have searched over the net and most of the guides for Egit either assume you work alone or that someone else clones and branches off to their own repo. However we are collaborating on the same project (a 2D RPG) and don't know how to properly use Egit to work together. Some of the problems we face:
1. We had the exact same copy of the project, he changed some of the methods we used, I changed some of the classes and resources we use. He committed and pushed to repo first. Now I cannot push or commit or even pull because of conflicts in the files (repo vs local) which Egit complains must be resolved.
2. How do you properly synchronize code that you are collaborating on? Lets say either one of us is first out to push to repo, what must the other (the puller) do to make sure his own code is not completely overwritten, only accept parts that have changed, parts that we think should be changed.
3. Do we always have to make a (new) local branch, pull to this, see changes, and merge the changes we want with the master/main? How do you properly do this.
Any input is most welcome, we are already much more efficient with our broken knowledge, more will only do good :)
Ok here are my answers:
We had the exact same copy ... because of conflicts in the files (repo vs local) which Egit complains must be resolved.
First you should make sure you use separate branches so that you can always commit.
Then you have to resolve any conflicts when you merge.
How do you properly synchronize code ...
Use separate branches to make sure code is ok before you pull it into master branch.
Do we always have to make a (new) local branch ...
Yes, git is built on the assumption that this is the best way to work. "Everything is local"
This is the way I or we usually use branches:
Main dev branch (Master)
Project branch, used to merge in features added by this project. When all features have been added and seems to work this is pushed/merged into the master branch.
Developer branches, every developer has his/her own branch to develop a specific feature before pushing/merging that into the project branch.
What could sometimes be good to have is also specific release branches. I.e. when a project has merged all added features into the master branch and everything seems ok, a release branch is created for regression testing. This branch will eventually contain the released software when all testing has been done.
The benefit of doing a separate release branch is that the main branch can continue to be developed, but if a fast bugfix has to be done on an earlier release it can be done on that release branch and then later merged into the master branch.
//jk
A repo has various pull-requests and other fixes in some of its forks (no pull-request) that are noted in comments in the 'Issues' section. How do I go about gathering all the scattered fixes and committing them?
This is the main repo I refer to.
Some of the commits I would like to add are in this fork and this fork.
Plus miscellaneous ones mentioned in this pull-request (which has not been pulled, even though requested ages ago), namely the pbaker ones.
What is the best way to go about creating a new repo/fork that combines them all?
You can:
add those forks as remote repo (git remote add)
fetch them: git remote update (see "pull/push from multiple remote locations")
merge or cherry-pick the commits you want.
Now, this isn't the ideal workflow: you should pull from only one fork (and only if you can apply its fixes in a fast-foward manner), then ask the other forks to rebase their history on top of your own updated branch.
And then repeat the process for another fork.
However, in the case of truly distributed development, this "ideal" scenario doesn't scale well.
Hence the idea to merge/cherry-pick everything you need, even if that means for the forks to reset their own master branches.
I am new to version control. I often hear these words Merging and Branching. I also see different developers working in different branches.
Can someone explain the flow on this. What is the difference between Merging and Branching. When to go for Merging and Branching
Branching is about isolating a development effort in a specific history, parallel to the main one.
See "When should you branch?": you branch when you cannot commit on the current branch (because it would break the work of your colleagues)
Merging is about reconciling two different branches.
You merge when you want to take into account in your branch the changes of the other branch you need to merge.
The workflow depends on the tools.
SVN offers either merge-based development or trunk-based development.
Tools with easier branching capabilities (like Git for instance) offer a workflow based on the various development lifecycle steps:
In the concept of git,
Branch is just a pointer to a commit, and will be advanced to the new commit when you make new commit to that branch.
Git has 2 types of branches: local and remote.
git can merge any single commit, not only the head of a branch.
I take the most simple merging workflow as an example.
2 developers are working on a project.
They are working independently based on the same version.
They share the master (main) branch via a server when they complete.
The first developer commit changes and push to the remote branch first. The second developer then synchronizes the changes by pulling changes made by the first developer.
A merge commit will be automatically created.