OpenStack install on Ubuntu 16.The other day at work I had a mildly annoying problem – merging only selected files between a test and production branch in github. Zabbix 3 install on Ubuntu 14.04 & adding hosts / items / graphsĭatadog - Monitoring with PagerDuty/HipChat and APMĬontainer Orchestration : Docker Swarm vs Kubernetes vs Apache Mesos Nagios - The industry standard in IT infrastructure monitoring on Ubuntu Nagios on CentOS 7 with Nagios Remote Plugin Executor (NRPE) New Relic APM with NodeJS : simple agent setup on AWS instance Linux - General, shell programming, processes & signals. Samples of Continuous Integration (CI) / Continuous Delivery (CD) - Use casesĪrtifact repository and repository management Sponsor Open Source development activities and free contents for everyone. Git Cheat sheet - quick command reference.Git/GitHub via SourceTree IV : Git Reset.Git/GitHub via SourceTree III : Git Work Flow.Git/GitHub via SourceTree II : Branching & Merging.Git/GitHub via SourceTree I : Commit & Push.Setting up a remote repository / pushing local project and cloning the remote repo.GIT on Ubuntu and OS X - Focused on Branching.Undoing Things : File Checkout & Unstaging. ![]() One page express tutorial for GIT and GitHub.This is the default behaviour when merging an This is the defaultĬreate a merge commit even when the merge resolves as aįast-forward. Pointer, without creating a merge commit. When the merge resolves as a fast-forward, only update the branch Here is an additional info from man git merge: "Merge branch 'car'" - Then, we merged it."Added 2nd commit to the car branch" - We went to the 'car' branch, modified the 'Book1', and did commit."added a line at the beginning" - The master was updated (in the previous section).It shows us how we went off the 2nd commit: The most recent two lines of log:Īlso, we can see more info from the log if we use -graph option: # Lines starting with '#' will be ignored, and an empty message abortsĬheck the log on the 'master' branch if we have any log regarding the git log -oneline # especially if it merges an updated upstream into a topic branch. # Please enter a commit message to explain why this merge is necessary, We need to close the editor to move on to the merge process: In our case, sublime popped up, and added a line at as shown below. So, we need to use a flag : -no-ff which means "no git merge -no-ff carĭuring the merge process, it will ask us how the message look like. We don't want to just append and we want to make a new commit that says we merged files here. We'll tell git that even if we're just appending, we want to make a commit. Now we want to make commit and see the log is saying 'merge'. Nothing to commit, working directory cleanĤ552553 Added 2nd commit to the car branch Now we do git add git commit -m "Added 2nd commit to the car branch" No changes added to commit (use "git add" and/or "git commit -a") " to discard changes in working directory) This is our 2nd commit on the 'car' branch. Let's switch to the 'car' branch and make add another line git checkout car Now we want to take a little bit different approach to make it clear. It's not a mistake on our side and the git did what it supposed to do. The logs simply says "added a line at the beginning" even though we clearly did merge. ![]() When we simply look at the 'master' branch log, the merge we've done in the previous section is not clear whether it's a merge or git log -graph -oneline Picture source: What's a Fast Forward Merge?. We can create a new commit to represent the merge even if git would normally fast forward by passing "-no-ff". If master has not diverged, instead of creating a new commit, git will then simply point master to the latest commit of the feature branch. If master has diverged since the feature branch was created, the merging the feature branch into master will create a merge commit. If we check the log on our 'master' branch, we can see the new merge is recorded there right at the top of the git log -oneline This kind of merge is called fast-forward merge as we can see from the output git branch Acutually, all we have to do is to append our update to the 'master' branch. So, merging the 'car' branch to the 'master' branch is going to be straight forward. Since we checked out the 'car' branch, the 'master' branch hasn't been changed at all. ![]() ![]() Let's look at the difference between 'master' and 'car' lsĪs we can see the 'car' branch has additional line: "This is in 'car' branch". We are currently on the 'master' branch and we have another branch called git branch
0 Comments
Leave a Reply. |