git-branch

git how to find commit hash where branch originated from

拈花ヽ惹草 提交于 2019-11-27 17:48:59
Pretend I branched from my master branch to a topic branch, and then I did a few commits on my topic branch. Is there a command that tells me the commit hash on the master branch that my topic branch originated from? Ideally, I wouldn't have to know how many commits I've made ( trying to avoid HEAD^5 ). I've googled and SO'd around and can't seem to land on the answer. Thanks! knittl use git merge-base master your-branch to find the best common ancestor between two branches (usually the branching point). You can use git reflog show --no-abbrev <branch name> . It will output all changes made to

Move commits from master onto a branch using git

南楼画角 提交于 2019-11-27 17:48:02
I'm trying to learn how to use Git effectively and I'm wondering how I should (good practice/bad practice?) solve the following case: Say I have the following chain of commits in master: Initial commit Commit 1 Commit 2 Commit 3 Then I realize that what's done in the last two commits is completely wrong and I need to start from Commit 1 again. Questions: How should I do that? Can I move Commit 2 and 3 to a separate branch to keep for future reference (say they weren't that bad after all) and continue working from Commit 1 on master? VonC git branch tmp # mark the current commit with a tmp

How to 'git pull' into a branch that is not the current one?

老子叫甜甜 提交于 2019-11-27 17:16:21
When you run git pull on the master branch, it typically pulls from origin/master . I am in a different branch called newbranch , but I need to run a command that does a git pull from origin/master into master but I cannot run git checkout to change the selected branch until after the pull is complete. Is there a way to do this? To give some background, the repository stores a website. I have made some changes in newbranch and deployed them by switching the website to newbranch . Now those changes have been merged upstream into the master branch, I am trying to switch the website back to the

What is the difference between git push.default=current and push.default=upstream?

坚强是说给别人听的谎言 提交于 2019-11-27 17:11:50
The man page for git-config lists these options for push.default: nothing - do not push anything. matching - push all matching branches. All branches having the same name in both ends are considered to be matching. This is the default. upstream - push the current branch to its upstream branch. tracking - deprecated synonym for upstream. current - push the current branch to a branch of the same name. In most cases I would assume that pushing to a branch's upstream branch would be the same as pushing to a branch of the same name, since the upstream branch would normally have the same name, and

How can I display the current branch and folder path in terminal?

梦想与她 提交于 2019-11-27 17:04:50
I've been watching some of the Team Treehouse videos and they have a very nice looking terminal when working with Git. For example they have (something similar): mike@treehouseMac: [/Work/test - feature-branch-name] $ git add . mike@treehouseMac: [/Work/test - feature-branch-name] $ git commit -m "Some feature." mike@treehouseMac: [/Work/test - feature-branch-name] $ git checkout master mike@treehouseMac: [/Work/test - master] $ git status How can my terminal show me some useful information of what branch I'm on, with colors to distinguish bits of the data I want? Is there some sort of de

How do I run git log to see changes only for a specific branch?

こ雲淡風輕ζ 提交于 2019-11-27 16:35:15
I have a local branch tracking the remote/master branch. After running git-pull and git-log , the log will show all commits in the remote tracking branch as well as the current branch. However, because there were so many changes made to the remote branch, I need to see just the commits made to the current local branch. What would be the Git command to use to only show commits for a specific branch? Notes: Configuration information: [branch "my-branch"] remote = origin merge = refs/heads/master Assuming that your branch was created off of master , then while in the branch (that is, you have the

How to delete the old history after running git filter-branch?

六月ゝ 毕业季﹏ 提交于 2019-11-27 15:54:28
问题 Suppose I have such tree: ... -- a -- b -- c -- d -- ... \ e -- a -- k and I want it become just ... -- a -- b -- c -- d -- ... I know how to attach branch name to "e". I know that what I'm going to do will change history, and this is bad. Also I guess I need to use something like rebase or filter-branch. But how exactly - I'm lost. Ok. Situation is following: I have rather big tree now (like this) s -- p -- r / a -- b -- c -- d -- e --- g -- w \ \ t -- p -- l y -- k but in my one of first

Git branch name - case sensitive or insensitive?

爷,独闯天下 提交于 2019-11-27 14:40:11
I am a new git user and recently been handed with an out of date git repository to look after. This is the original state ( output by git show-branch): ! [cr232] CR 232 Release * [dev] Style Changes --------------- * [dev] Style Changes * [dev^] SMS 5.4 * [dev~2] Logo Change * [dev~3] SMS 5.3 * [dev~4] SMS 5.2 * [dev~5] SIT R-0.3.3 EDW SMS Layers * [dev~6] SIT Release R 0.3.0 +* [cr232] CR 232 Release +* [cr232^] Dashboard Fix +* [cr232~2] Release for system testing Note that there is a branch called ‘dev’ at this point. Note that highlighted there are several references to dev (i.e. dev, dev^

Merging one change to multiple branches in Git

笑着哭i 提交于 2019-11-27 14:35:41
问题 I am used to having one main branch (master) and working in topic branches. But I'm working on a project now with two main branches (master and experimental) and I am unsure how to best merge my topic branch into both? Is this the right way to do it? If not can someone let me know the right way. (master)$ git checkout -b bugfix # do bug fix here (bugfix)$ git commit -a -m 'Fixed bug.' (bugfix)$ git checkout master (master)$ git merge bugfix (master)$ git checkout bugfix (bugfix)$ git rebase

Keep commits history after a 'git merge'

三世轮回 提交于 2019-11-27 13:07:26
问题 When I work on two different features (on two different branches created from the master ) it is quite annoying that I will not have the commit history when I proceed with merging. I'll explain better. When I finish work on Branch-A , I merge it into master . And that's fine, if I git log I see all the commits I made on Branch-A . Instead , when I finish work on Branch-B and I try to merge it to master (after that Branch-A has been already merged), I have to specify a commit message for the