git-branch

git branching - how to make current master a branch and then revert master back to previous version?

人盡茶涼 提交于 2019-12-21 02:41:14
问题 This is probably quite simple but I'm currently a git noob and haven't quite got my head round the git branching model yet. Suppose I currently have no branches other than master , but now I've made some changes since my last commit that I've decided I don't want to keep (note: the changes are not committed yet). I don't want to get rid of these changes just yet though - I'd like to put them in their own branch (called e.g. experimental_stuff ) and then continue development from my previous

Git: merge only the changes made on the branch

自闭症网瘾萝莉.ら 提交于 2019-12-20 17:28:29
问题 G---H // Release Branch / / A---B---E---F--- // master \ \ C---D--- // bug fix branch Based on our particular needs for our project, it is quite common for the above scenario to occur. We have our master/dev branch with some commits. Then we get a bug report and start fixing that on the bug branch (commits C and D above). More commits happen in the dev branch in the meantime. Next we are told we need to create a release for a customer which cannot include the changes introduced by commits B,

Git: best way to remove all changes from a given file for one branch

懵懂的女人 提交于 2019-12-20 12:42:21
问题 I have a bit of a messy branch with 20 or so commits, and I'm preparing for a merge back to master. I've rebased it off master, and looking closer, I realise that there are files being modified in ways that are totally irrelevant to this branch, and not ready to be committed. The changes to those files aren't confined to specific commits. So basically, I don't want anything to do with those files to be included in this branch if possible. Is there a good way to go about this? My fall back

git, change on local branch affects other local branches?

随声附和 提交于 2019-12-20 10:29:11
问题 I have a master branch now for some testing other things I made a branch A I checkout branch A modify the file and when I checkout master again the changes are there as well. On other repositories I have the right behaviour 回答1: Uncommitted changes will move from one branch to other. To keep them separated, you must stash those changes before moving to another branch. When you return to your branch, you can apply those changes to retrieve them. As seen below: >$ git status On branch branch_1

How to change the starting point of a branch?

雨燕双飞 提交于 2019-12-20 09:56:24
问题 Usually I create a branch by running a command like git checkout -b [branch-name] [starting-branch] . In one case, I forgot to include the starting-branch , and now I want to correct it. How do I do so after the branch has already been created? 回答1: The short answer is that once you have some commits, you want to git rebase them, using the long form of git rebase : git rebase --onto newbase upstream . To find out how to identify each of these, see the (very) long answer below. (Unfortunately,

Git repository created without a master branch

可紊 提交于 2019-12-20 09:53:34
问题 I want to create a new shared git repository for a new project (on a VM). I ran git --bare init from /.../git/new_proj.git , but a master branch is not created in the .../git/new_proj.git/refs/heads directory. I also ran sudo chmod 777 -R on my directory, but it didn't help, and still no master is created after the init command. Edit: I even tried to use git init (without the bare flag), but still the master branch was not created. Google wasn't much help in this matter... Anyone know what

How do I move a commit between branches in Git?

≡放荡痞女 提交于 2019-12-20 09:47:49
问题 I'm sure this is a simple thing that has been asked and answered, but I don't know what terms to search for. I have this: /--master--X--Y A--B \--C--D--E Where I commited C, D, and E (locally only) on a branch, but then I realized that D and E are really independent of C. I want to move C to its own branch, and keep D and E for later. That is, I want this: /--C /--master--X--Y A--B \--D--E How do I yank C out from under D and E? 回答1: You can use git cherry-pick to grab C, and put it on Y.

Git list of branch names of specific remote

牧云@^-^@ 提交于 2019-12-20 09:22:04
问题 How can it possible to get all names of some remote origin branches? I started from --remote --list options, but got redundant origin/HEAD -> origin/master message and branches from the another origin. $> git branch --remote --list origin/HEAD -> origin/master origin1/develop origin1/feature/1 origin1/feature/2 origin1/feature/3 origin1/master origin2/develop origin2/feature/1 origin2/feature/2 origin2/master Branches of specific origin could be matched with <pattern> option, but redundant

block push of trivial merge to git server

别等时光非礼了梦想. 提交于 2019-12-20 08:44:04
问题 A while back I asked our developers to use rebase instead of merge before pushing. Eliminating trivial merges makes for a much easier to follow commit graph (ie: gitk, git log). Sometimes folks still accidentally do trivial merges, then push. Does anyone have handy or have tips for writing a server-side hook that blocks trivial merges? By "trivial merge", I mean a merge without conflicts. Here's an example, and here's a better explanation of a trivial merge in git. Update Wed Nov 10 01:26:41

block push of trivial merge to git server

落花浮王杯 提交于 2019-12-20 08:42:16
问题 A while back I asked our developers to use rebase instead of merge before pushing. Eliminating trivial merges makes for a much easier to follow commit graph (ie: gitk, git log). Sometimes folks still accidentally do trivial merges, then push. Does anyone have handy or have tips for writing a server-side hook that blocks trivial merges? By "trivial merge", I mean a merge without conflicts. Here's an example, and here's a better explanation of a trivial merge in git. Update Wed Nov 10 01:26:41