git-branch

How do I synchronize two branches in the same Git repository?

ⅰ亾dé卋堺 提交于 2019-12-20 08:38:40
问题 Here's a common workflow hurdle I encounter often: master is our "stable" branch $ git status # On branch master nothing to commit (working directory clean) Create a module on a branch $ git checkout -b foo $ echo "hello" > world $ git add . $ git commit -m "init commit for foo module" $ git checkout master $ git merge foo Do work on master or other branches Over the next couple weeks, more code will be committed to master directly and by other branches. The foo branch will go untouched for

Git branch deletion

为君一笑 提交于 2019-12-20 07:58:31
问题 In Git, what does "deletion" of a branch mean? Will it be gone from the repository? Or will it still be navigable to via git branch ? What I really want to do is mark a branch as "dead end", i.e., the branch is so far from master, that nobody should use it as a starting point, though there were some good ideas down that branch, so we'd like to keep it, for reference. 回答1: You can delete the branch, but tag it first, so that it's history doesn't disappear. This way, the branch doesn't show up

How to compare two git branches and filter the differences by commit message?

让人想犯罪 __ 提交于 2019-12-20 07:31:41
问题 I have a release branch named release/X.X.X.X which contains all feature branches I want to deploy to production. The release branch is made on top of master which is the current state of production. On every release day I make sure our release branch contains only those changes planned for the release. I use this command to compare the release and master branch: git log release/X.X.X.X ^master --no-merges . I then manually check the commits for keywords like "SHR-1234" which represent ticket

git workflow with 3 branches advice

倾然丶 夕夏残阳落幕 提交于 2019-12-20 04:50:00
问题 I'm working on a project where we're trying to get to grips with using git in the most efficient manner (for us) and have decided to create 2 branches for 2 sub-teams to work on, along side the master branch. Sometimes we will commit into master if it's something generic that should go into both branches and then we want those changes in the both of the other branches. Should that be a merge or a rebase into the 2 other branches? Is this an insane workflow to be going down the route of? If so

Git: send commit to another branch so I can work and merge back, without (very slow) checkout?

为君一笑 提交于 2019-12-20 03:27:11
问题 I have 2 branches, the main one and the one I'm working on a parallel release. A --> B --> C (master) \ -> E --> F (parallel) The parallel branch will always merge from master . Always. And modify upon it. A --> B --> C --> D --> H (master) \ \ *merge* -> E --> F --> G --> J (parallel) This is easy to do if I switch branches. But, if I'm working on parallel , can I do this without switching branches ? The problem with switching is that it takes a long time to go back and forth (specially on

git change default branch (gitolite)

北慕城南 提交于 2019-12-19 09:50:02
问题 I've got a repository with branches: master and devel. Master is the default one. I want to rename master into prod and make it default (and push it to the server). How to do this? Repository is hosted in gitolite (if it matters). 回答1: You need to have access to the server in order to change the symbolic-ref of HEAD to the branch you have pushed there ( prod ). git-symbolic-ref HEAD refs/head/prod I tentatively proposed a way to do that from a client at the end of "How do I change a Git

Git listing non-existent remotes

别等时光非礼了梦想. 提交于 2019-12-19 07:04:11
问题 I recently made some changes to my remote repos in my Git repo config file. I renamed the remote names, changing my origin to another remote repo and renaming my old origin. For example, I had this previously: [remote "origin"] url = blah blah [remote "future"] url = blah blah I went in and changed them so they look like this: # formerly the origin [remote "old-origin"] # formerly the future repo [remote "origin'] But now, when I type git branch -a , I am seeing branches listed from the old

How can I color Git branches based on their names?

耗尽温柔 提交于 2019-12-18 15:52:37
问题 I have a number of branches in my local git repository and I keep a particular naming convention which helps me distinguish between recently used and old branches or between merged and not merged with master. Is there a way to color branch names in the output of git branch according to some regexp-based rules without using external scripts? The best I've come up with so far is to run git branch through an external script, and create an alias. However, this may not be very portable... 回答1: git

How to make existing branch an orphan in git

亡梦爱人 提交于 2019-12-18 15:33:09
问题 Is there a way to make an existing branch an orphan in git? git checkout --orphan seems to only create a new orphan? 回答1: Do I understand you right, that you want the orphaned branch to already have a history of commits? If so, here's a solution. First you need to pick a commit to start the new branch at. In my example this will be HEAD~2 , sha1=df931da . Say, we've got a simple repo. git log --oneline --graph --decorate shows the following: * 4f14671 (HEAD, master) 4 * 1daf6ba 3 * df931da 2

Initializing private repositories on production server

不羁岁月 提交于 2019-12-18 13:48:20
问题 What I want to do now is to initialize a private repository on my production server in to app's www folder (ex: /var/www/app.com/web/) and then clone it as a staging repository to my testing site (ex: /var/www/test.com/web/app.com/) and finaly clone from staging to local to work with the code. Am I planning it the right way? I am following these tutorials to learn more about setting the "git server" and initialize private repositories: http://progit.org/book/ch4-4.html https://moocode.com