git-branch

how to manage obsolete branches on github

情到浓时终转凉″ 提交于 2019-12-11 02:15:05
问题 I usually develop new features of my codes in dedicated branches, then merge them to master. The problem with this is that after some time I have a lot of obsolete branches that are cluttering the github interface, where there might be instead branches which are actively developed. Is there a way to archive them somehow, or should I just delete them, as the commits have already been merged? 回答1: If you have already merged branches and have no need to develop on them anymore, then it's safe to

How do I fast foward branches without switching to them?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 01:28:38
问题 I currently am on my master branch, and my stage is dirty. I don't want to commit and I already have too many stashes to stash my changes (or am I too lazy ?). I would like to move fast foward some branches without switching to them (remember, my stage is dirty). How could I fastfoward optim to mobile ? or optim to master (my current branch) ? image: http://i.stack.imgur.com/WUPeq.png 回答1: Note: a branch name is merely a pointer to a (single) commit. The thing we tend to think of as "the

Overwrite the master branch with a orphan branch in git

两盒软妹~` 提交于 2019-12-10 23:46:53
问题 I've created a new orphan branch with git checkout --orphan orphan-branch and made a lot of commits on that branch. Now I want to replace the master branch with the newly created orphan-branch , all the files and the history of the master branch should be replaced by the files and the history of the orphan branch. What is the best way to do this? 回答1: To replace the history and old file of the master branch you need to do a forced update on it. git push origin +your_orphan_branch_name:master

git clone does not checkout active branch

北城以北 提交于 2019-12-10 21:32:45
问题 I have a remote bare repository with two branches 'master' and 'testing', where HEAD refers to 'testing'. When cloning this repository git checks out 'master', if 'master' and 'testing' are on the same revision (i.e. HEAD == testing == master). Only if 'testing' is one (or more) commit(s) behind or ahead, git clone checks out the 'testing' branch on the local side. I tried this with git 1.7.5 on Mac OS X (10.6.8). Addendum: I just tried the same with a non-bare repository: mkdir A cd A git

Retrieving branch names from within a post-checkout hook

↘锁芯ラ 提交于 2019-12-10 20:41:19
问题 When switching from one branch to another in Git, is there any way to retrieve the names of both branches from within the post-checkout hook? So assuming I were to run the following two commands: $ git branch * branch_a branch_b master $ git checkout branch_b Switched to branch 'branch_b' I'd be looking for the following two strings (in the post-checkout hook): "branch_a" "branch_b" 回答1: You can use git reflog inside your hook to get the previous and next branch. Here a simple working example

How to prevent tracked config files from being changed by merges in git?

南笙酒味 提交于 2019-12-10 17:52:58
问题 I have a web project with two git branches (developing and production) and each one connects to a different server (dev and prod). Each branch has a set of tracked config files, such as different URLs, database options, sql exported files, etc. which are different on both branches. Every time I try to merge those branches I get a lot of conflicts in these settings files which need to be resolved manually, but every now and then I miss something. In short, it is a nightmare. My question is

How can I quickly check which Git branch is the newest?

 ̄綄美尐妖づ 提交于 2019-12-10 15:15:58
问题 For example if have 4 branches on git like this: branch1 branch2* (current branch) branch3 (newest commits here) master (oldest) My questions are: How can I check if my current branch is the newest right from the git command line? If not, which branch is the most up-to-date? I mean which branch contains the latest commits? How can I list all the commits in this git repository (in any branches) which are newer than my branch without switching away from the current branch? 回答1: Edit : You'll

Always ignore a certain commit on merge in git

社会主义新天地 提交于 2019-12-10 13:55:49
问题 I am working on my first project using git and have ran into an issue. The repo contains a a client/server app. I have a 'master' and 'test' branches, with the intent that master is always the same as what's deployed. My problem there are 3-4 places in the codebase where the server URL is stored. I want to change this in the 'test' branch, but not in the 'master' branch. The problem is, of course, that whenever I want to merge back to 'master', git wants to put this change in 'master'. I can

fetch and checkout a remote git branch in just one command

ε祈祈猫儿з 提交于 2019-12-10 13:05:33
问题 If I have local repo with a remote $REMOTE already set up and a new branch $BRANCH exists on the remote repo that I haven't fetched, yet can I fetch that branch and check it out into a tracking local branch of the same name in a single command ? I can achieve the desired result in two commands either with git fetch $REMOTE $BRANCH git checkout $BRANCH # or more explicitly git checkout -b $BRANCH $REMOTE/$BRANCH or (inspired by this answer to Question How do I check out a remote Git branch?)

Can gitolite prevent branch deletes?

我的未来我决定 提交于 2019-12-10 11:53:34
问题 Is it possible to set up gitolite acls to allow a user to read, write, and push, but not to delete branches? 回答1: You should be able to use as a general rule for all repositories: repo @all RWCD dummy-branch = foo The ' D ' is a "deletion" type of permission, which will authorize the deletion of a dummy-branch , but will make all your existing RW+ rule deny deletion (because they don't have a ' D ') 来源: https://stackoverflow.com/questions/13275420/can-gitolite-prevent-branch-deletes