git-branch

How do I commit only some files?

一世执手 提交于 2019-11-26 10:05:43
问题 I have two projects. One is the \"official\" project and the second is a light modification (some files added). I created new branch and I put new files to them. But in during development some files common to both branches is changed. How do I commit only these files? 回答1: I suppose you want to commit the changes to one branch and then make those changes visible in the other branch. In git you should have no changes on top of HEAD when changing branches. You commit only the changed files by:

Git merge master into feature branch

陌路散爱 提交于 2019-11-26 10:03:50
问题 Let’s say we have the following situation in Git: A created repository: mkdir GitTest2 cd GitTest2 git init Some modifications in the master take place and get committed. echo \"On Master\" > file git commit -a -m \"Initial commit\" Feature1 branched off master and some work is done: git branch feature1 git checkout feature1 echo \"Feature1\" > featureFile git commit -a -m \"Commit for feature1\" Meanwhile, a bug is discovered in the master-code and a hotfix-branch is established git checkout

Is there a better way to find out if a local git branch exists?

北战南征 提交于 2019-11-26 08:47:37
问题 I am using the following command to find out if a local git branch with branch-name exists in my repository. Is this correct? Is there a better way? Please note that I am doing this inside a script. For this reason I\'d like to use plumbing commands if possible. git show-ref --verify --quiet refs/heads/<branch-name> # $? == 0 means local branch with <branch-name> exists. 回答1: As far as I know, that's the best way to do it in a script. I'm not sure there's much more to add to that, but there

How do I rename both a Git local and remote branch name?

断了今生、忘了曾经 提交于 2019-11-26 08:43:26
问题 I have four branches like master -> origin/regacy, FeatureA -> origin/FeatureA. As you can see, I typed the wrong name. So I want to rename a remote branch name (origin/regacy → origin/legacy or origin/master) I try the command below: git remote rename regacy legacy But Git console returned an error message to me. error : Could not rename config section \'remote.regacy\' to \'remote.legacy\' How can I solve this problem? 回答1: You can't directly rename a remote branch. You have to delete it

How do I merge changes to a single file, rather than merging commits?

不打扰是莪最后的温柔 提交于 2019-11-26 08:39:44
问题 I have two branches (A and B) and I want to merge a single file from branch A with a corresponding single file from Branch B. 回答1: I came across the same problem. To be precise, I have two branches A and B with the same files but a different programming interface in some files. Now the methods of file f , which is independent of the interface differences in the two branches, were changed in branch B , but the change is important for both branches. Thus, I need to merge just file f of branch B

Git branch strategy for small dev team [closed]

风格不统一 提交于 2019-11-26 08:38:51
问题 We have a web app that we update and release almost daily. We use git as our VCS, and our current branching strategy is very simple and broken: we have a master branch and we check changes that we \'feel good about\' into it. This works, but only until we check in a breaking change. Does anyone have a favorite git branch strategy for small teams which meets the following requirements: Works well for teams of 2 to 3 developers Lightweight, and not too much process Allows devs to isolate work

Git branch command behaves like &#39;less&#39;

痴心易碎 提交于 2019-11-26 07:52:15
问题 When I use the git branch command to list all branches, I see the output of git branch | less . The command git branch is supposed to show a list of branches, like ls does for files. This is the output I get: How do I get the default behaviour of git branch ? What causes the paged output? I am using ZSH with oh_my_zsh (nothing for Git in there), and my .gitconfig looks like this: [user] email = myemail@mail.com name = Dennis Haegler [push] default = simple [merge] tool = vimdiff [core] editor

View a file in a different Git branch without changing branches

不羁岁月 提交于 2019-11-26 07:50:12
问题 Is it possible to open a file in a git branch without checking out that branch? How? Essentially I want to be able to open a file in my github pages branch without switching branches all the time. I don\'t want to modify it, just want to view it. 回答1: This should work: git show branch:file Where branch can be any ref (branch, tag, HEAD, ...) and file is the full path of the file. To export it you could use git show branch:file > exported_file You should also look at VonC's answers to some

What are the differences between local branch, local tracking branch, remote branch and remote tracking branch?

自闭症网瘾萝莉.ら 提交于 2019-11-26 06:51:53
问题 I just started using Git and I got really confused between different branches. Can anyone help me to figure out what the following branch types are? local branches local tracking branches remote branches remote tracking branches What is the difference between them? And how do they work with each other? A quick demo code will be really helpful I guess. 回答1: A local branch is a branch that only you (the local user) can see. It exists only on your local machine. git branch myNewBranch # Create

What is the best (and safest) way to merge a Git branch into master?

烂漫一生 提交于 2019-11-26 06:08:55
问题 A new branch from master is created, we call it test . There are several developers who either commit to master or create other branches and later merge into master . Let\'s say work on test is taking several days and you want to continuously keep test updated with commits inside master . I would do git pull origin master from test . Question 1: Is this the right approach? Other developers could have easily worked on same files as I have worked btw. My work on test is done and I am ready to