I have been working on a project which is on git master branch.
As we are 3 developers work on this master branch and modify the same files, we get much conflicts.
To avoid these conflicts, do I need to create separate branches from the same master branch.
Please suggest me a good development procedure with git branching.
Many shops use the Git Flow model.
This page compares several Git Workflows.
Please refer Atlassian Git Workflow tutorial for centralized and decentralized model.
https://www.atlassian.com/git/tutorials/comparing-workflows/
Related
We currently support two branching strategies; gitflow and trunk-based dev. My company started using what I'd call a hybrid (read not correctly IMO) gitflow model, but the direction of the company is to move to trunk-based development. I like the direction, but what's the best way to do this? I'm looking for best practices, but was unable to find this topic discussed online.
We use GitHub for SCM
In our hybrid gitflow branching strategy, our git projects are not currently (IMO) using the gitflow "master" branch correctly.
Should we:
Create new git projects in GitHub and archive the older gitflow based git projects
Block access to the "master" branches in the gitflow based git projects
Delete the "master" in the gitflow based git projects, and then follow trunk-based dev
Thanks
I was in a similar situation and wanted to switch from Git-Flow to Trunk-Based development.
This is how I ultimately solved the dilemma of a headache-filled attempt of merging massive amounts of code from 'dev' to 'master/main':
TL;DR: Replace 'main/master' with 'dev's code entirely, in your OS. Commit changes. Merge 'dev' into 'master/main'. Lock dev.
Detailed process -
Switch to 'dev' branch
Make a copy of 'dev' on your local drive in another folder
Switch to 'master/main'
Delete all contents from your local drive for this branch's folder, EXCEPT for the .git folder
Copy all the contents, EXCEPT the .git folder, from the backup/copy of 'dev' from step 2 to the 'master/main' branch's folder
Do a 'git status' and see that there are a ton of changes
git commit, and git push
Now your 'master/main' contains exactly what 'dev' does.
Finally merge 'dev' into 'master/main' so history/tooling shows that they converged
Lock the dev branch
Implement Trunk-Based development and CI best practices
Best wishes!
At the new workplace where I work, in the past, the main project was split in two branches, because different customers began to have very different requirements. A pretty common scenario I guess.
Now, I'am not a developer but a sysadmin, and not an expert of git, but I was wondering if in these cases usually is the correct approach to use branches, because in my understanding a fork would be more adapt.
What the CTO is asking me to do, is to migrate this branch, into a new git repository. But he also says that he wants to still be able to perform comparisons between commits, therefore (in eclipse + egit) to right-click on workspace > team > show in history > select the commits he wants to compare > click on compare to each other. I believe that these requirements conflict to each other, so my main question is: is it possible to compare commits of different git repositories?
My second question is, if a project with the same core that starts to require different features, should be branched forked or moved to a new repository?
Hope my question is not too broad
There is no concept called fork in Git. Git hosting services, such as Github or Gitlab, provide such a feature. As far as Git is concerned, a fork is essentially just a branch. And also, every clone of a repository - even local repositories - are essentially forks.
To split up your repository into two repositories that have a fork relationship, first just create a clone of the repository. And then delete branches in both repositories that refer to commits of the now-other-repository.
The usual approach to compare forks is to add a remote to the other remote. This is possible in your case too, since you have common commits in both repositories, before the forking-point. More on remotes here: What is "git remote add ..." and "git push origin master"?
We want to migrate existing TFVC to TFS-GIT using existing team project with multiple branches. I found some tutorials that I could follow to migrate every branches. But their is something that makes me wonder if we can maintain or re-arrange our TFVC branch hierarchy in TFS-GIT?
Let us say we have branch hierarchy like this:
Prod <---> Pre-Prod <---> TEST <----> DEV
And during the migration process into TFS-GIT, we want to re-arrange the branch hierarchy depend on our discretion. Like for example I want to have something like this in TFS-GIT:
Prod <---> Pre-Prod <---> DEV <----> TEST // Just an illustration of what I want.
Is someone here have achieved what we want to do? Can you point me out into the right direction?
Technically, we can migrate Prod branch as master branch and branch out Pre-prod. But for the existing TFVC Dev we have a lot on-going work and change-sets.
Disclaimer : This is my first to do it and I made a research but most of the tutorial I found is only one branch can be migrated. But how about the branch hierarchy? Apology for a naive question.
Migrating all branches from TFVC to git using git-tfs
https://github.com/git-tfs/git-tfs/blob/master/doc/usecases/migrate_tfs_to_git.md#fetch-all-the-history-for-all-branches
Ps: please fix your question because what you call git-tfs is in fact TFS-git (git-tfs is the tool https://github.com/git-tfs/git-tfs/)
I am planning to add my iOS project to GIT hub and I am new to the GIT branching and taging.
Please suggest a simple and good branching structure for development and production.
If i create one branch for development and one for production(master), is it possible to create sub branches under development?
Help is highly appreciable.
You can branch from any commit in git. All branches are equal. Why don't you try it out?
SCM organisation tends to be project-specific, so, whatever works for you is good. Your clients should never see your entire repository anyway.
First of all, branching in Git is unlike branching in Subversion or any other Central VCS.
Guess you need one major branch, and from there you can make all possible branches you need. Just remember to merge what you want to keep.
E.g. you branch for production (guess solving problems (branch even per problem)) and you branch for development (sub branching again if needed). And later on you can combine (merge) the changes from the production branch back to the master and all the stuff from your development branches that you want to keep.
But there is no best way - that depends on your use cases.
I usually branch per problem (production / issues) and merge it back if solved.
The development branch(es) I only add when needed (f.i. before acceptance testing).
YMMV.
Assume you have a tarball named ios_project.tar.gz with your initial work. You can place it under git revision control as
follows.
$ tar xzf ios_project.tar.gz
$ cd project
$ git init
Git will reply
Initialized empty Git repository in .git/
You've now initialized the working directory--you may notice a new directory created, named ".git".
Let the master be as is. I would recommend you to create two branches one for development and another for production. Do all your code modifications which you are unsure of in your development branch, and when you are sure about your work, push it to the production branch and apply a tag on it so that it is each to track the production line at a later stage.
In addition to this if you would like to share it with others, then have the repository as a shared directory. And clone it on any other development machine, create a local branch tracking the development branch on this machine, do changes, push to origin.
Following set of commands would be useful at a very basic level:
git clone git#repository_path_on_network/folder_name
git branch usrname_activity_dev --track origin/branch_in_repository
git checkout usrname_activity_dev
git add filenames
git commit -m "comments"
git push origin usrname_activity_dev:branch_in_repository
git checkout local_production_branch
git rebase usrname_activity_dev
git push origin local_production_branch:production_branch_on_repo
git tag tag_name
git push origin local_production_branch:production_branch_on_repo --tags
These are very basic commands. I would suggest you to further go through the internet. You will find a lots of commands according to every situation you are in.
Take a look at Git flow. Python scripts to help apply this are available here.
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.