custom pages

adunit2

adunit3

adunit4

Nov 27, 2012

How to create a patch in Git Version control

For example, you have master and new feature branches in your remote repository. Always any new enhancement work will be made on new feature branches and once enhancements are done those changes will be merged into master.
Suppose in your new feature branches having 20-30 commits, while merging with master, history will be show all those 20-30 commits and also revert back into our previous commits(suppose some bugs came so that we have to move previous enhancement merge fixes) will be bit headache.

For that better we have to create patch(it will create a single commit, will have all changes) than it will apply to master branch so that going back to previous commits it will be very easy.

* git checkout new_feature
* git diff master >> user_defined_patch_name.patch

It will create a patch file in your current branch, than checkout to master branch than apply.

* git checkout master
* git apply user_defined_patch_name.patch
* git add .
* git commit -m"commit message"
* git push origin master

It will create a single commit in your master repository.

How to checkout other branch particular file in your current branch in GIT


Suppose if you have two branches called "Master" and "test". In some cases if you want to checkout the master branch particular file/files in your test branch. That time the following git checkout command will be very useful.

* Move to your test branch using the following command,

git checkout test
# on test branch do the following command,
git checkout master -- file1.extentsion, file2.extention

The above command will checkout the files from the master branch and override your current branch(in this case "test") file changes.