Questions tagged [git-branch-sculpting]

Sculpting Git branches into various shapes and trees is an art. This tag is for all questions that involve sculpting and pruning commit trees into different forms.

The keys to understanding how to sculpt Git branches are the following:

  1. Git is just a tree of commits, with bookmarks (or Post-it notes) attached:

    Git repo diagram explaining branch relationships

  2. The final state of a series of commits can be made to be equivalent to squashing (rebasing) or merging those commits.

21 questions
48
votes
1 answer

Remove/hide git branches without deleting commit histories

Situation: I have a main repo with a main dev branch and lots of "experiment" branches sprouting off from it (e.g., exp1 and exp2). The purpose of these experiment branches is to serve as placeholders for experiments that generate numerical…
synaptik
  • 8,971
  • 16
  • 71
  • 98
15
votes
4 answers

How can I combine Git repositories into a linear history?

I have two git repositories R1 and R2, which contain commits from two periods of a product's development: 1995-1997 and 1999-2013. (I created them by converting existing RCS and CVS repositories into Git.) R1: A---B---C---D R2: K---L---M---N How…
Diomidis Spinellis
  • 18,734
  • 5
  • 61
  • 83
6
votes
2 answers

How to avoid rebase hell when merge commits are in the way?

I've got the following situation in my git tree: 1 -- 2 -- 3 -- 4 <-- master \ \ 5 -- 6 -- 7 -- 8 -- 9 <-- feature I want to rebase and squash everything from feature so that I can advance master with a single commit of the…
Alpha
  • 7,586
  • 8
  • 59
  • 92
6
votes
1 answer

Git interactive-rebase across multiple branches

I have a git repo that has a source file containing some sensitive content which I wish to remove (I don't want to delete the file, just amend its contents). The commit was pretty early on in the project development (when we only had a single…
Jon Bates
  • 3,055
  • 2
  • 30
  • 48
3
votes
3 answers

How do I show branches only inside one branch folder or subfolder?

I have organized my branches into folders and subfolders. I am only accessing my GIT repo through the CLI. I would like to be able to list only branches inside a branch folder. FEATURE/branch-1 FEATURE/branch-2 FEATURE/CURRENT/branch-000 …
Greg K.
  • 1,005
  • 2
  • 12
  • 20
3
votes
4 answers

Push to master commit made on a detached head

I wanted to redo changes from a previous commit. Maxims-MacBook-Air:hellodebug.com maximveksler$ git log commit 7f9dd753d39fd65b4272af713ef9c07a9f84f016 Author: Maxim Veksler Date: Sun Dec 28 09:12:17 2014 +0200 Imagine…
Maxim Veksler
  • 29,272
  • 38
  • 131
  • 151
2
votes
3 answers

How to remove all commits of a topic Git branch?

Suppose I have the following history: A---B---C----------D------------E master \ /\ / W1--X1--Y1 W2--X2--Y2 topic1 topic2 Is it possible to remove all topic branches and their…
Jacob Phan
  • 732
  • 2
  • 6
  • 20
1
vote
1 answer

Directly creating a new disconnected git branch

I have started a project and already have some commits. I would like to change my approach, and commit everything on a clean slate. Is it possible to commit a work tree as an unconnected first commit directly, or do I really need to use a temporary…
FooF
  • 4,323
  • 2
  • 31
  • 47
1
vote
1 answer

Move the most revent commits to a different branch

This is the Situation in my git repository: I have two branches "dev" and "fix" and need to move the three most recent commits on the fix branch to the dev branch. The head is on the last commit on the dev branch (E). So i need to go from this: dev…
oclaaf
  • 11
  • 1
1
vote
1 answer

Git branching strategy: During git rebase: couple file keeps conflicting

Branching main Branch called MASTER Created a Feature branch called FEATURE_BRANCH from MASTER Created a sub feature branch called SUB_FEATURE_1 FEATURE_BRANCH the parent from which main sun features are created. This branch has to be rebased from…
messia
  • 21
  • 3
1
vote
1 answer

How to create custom Grouping convention for Git Branch?

We recently moved from Perforce to Git and for technical reasons are have to stick with our old naming conventions for branches, which is: For Features: feature_abcd_123 For Bugfixes: bugfix_xyz_6789 For Custom: custom_mnop_8965 It is very difficult…
kishoredbn
  • 2,007
  • 4
  • 28
  • 47
1
vote
2 answers

Git: Creating branch out another branch showing on main level

I have created a new branch out another branch: master ---develpment ---------FeatureA But if I check the branch structure it shows FeatureA branch at the same level as develpment: git branch -a development * FeatureA master …
user2924482
  • 8,380
  • 23
  • 89
  • 173
1
vote
2 answers

Git: Multiple repositories in same folder with common files and code

I am looking at moving a large codebase to Git. There are many groups working on the codebase and multiple release builds are in [staggered] production. Some people will be working on ReleaseBuild A and ReleaseBuild B at the same time and will need…
0
votes
1 answer

Git rebase onto branch but treat all differences as commits

I have a bunch of bash scripts loaded from my .bashrc that I store in a private github repo so I can use them across computers. Each computer has its own quirks, so I have a branch for each one. I started this project on my work computer, so…
dx_over_dt
  • 13,240
  • 17
  • 54
  • 102
0
votes
1 answer

Fold out redundant divergent changes in Git

Given the initial state: A - origin/branch-1 | X A - origin/branch-2 | / M - master where both A commits make the same edit and where it has no overlap with the X commit, what is the best way to get things to the following state?: A -…
BCS
  • 75,627
  • 68
  • 187
  • 294
1
2