Menu

Fashion Trendy
  • Drop Down

    • Abstract
    • Model
    • Techo
    • Options
  • Photography Pictures Product

    Drop Menu

    • Crystal
    • Digital
    • Graphs
    • Settings
  • Menu

    Stack Now | C, C++, Linux, Design Patterns etc

    • Home
    • Digital Art
      • Pics
        • SEO 1
        • SEO 2
      • CSS
        • CSS 1
        • CSS 2
        • CSS 3
        • CSS 4
        • CSS 5
      • Jquery
        • Jquery 1
        • Jquery 2
    • Fashion
      • Product 1
        • Sub Item
        • Sub Item
      • Product 2
        • Sub Item
        • Sub Item
    • Photography
    • Design
    Go
    Home » linux » 2-Minute Guide for Patching and Generating a Patch File

    2-Minute Guide for Patching and Generating a Patch File

    Many times in the project, you need to generate a patch file or patch the file to your project. This 2 minute guide will help you how to generate patch using diff command and patch the file using patch command.

    Generating a Patch:
    The Patch file can be created using the below command:
    diff -rupN original_folder_name/ new_folder_name/ > mychanges.patch

    Applying a Patch:
    The patch file can be applied to your source code using below command:

    You need to go to the folder of source code and run:
    patch -p1 < kernel.patch

    For patching a single file:
    patch < changes.patch

    The two-minute guide for patching and generating is finished.

    If you have more time you can look below:

    patch -p: What does -pnum means?
    This will strip the smallest prefix containing num leading slashes from each file name found in the patch file. A sequence of one or more adjacent slashes is counted as a single slash. This controls how file names found in the patch file are treated.
    You can also use --strip=num instead of -pnum

    diff -rupN: what does -rupN means?
    -r stands for recursively comparing the subdirectories.
    -u stands for unified ouput format.
    -p shows which C function has the change.
    -N tells diff command that if file is found only in one directory, treat it as present but empty in other directory.

    If you still have more time, check the man pages of diff and patch:
    man patch
    man diff
    yash
    Add Comment
    linux
    Thursday, April 3, 2014

    facebook

    twitter

    google+

    fb share

    About yash

    Related Posts
    < Previous Post Next Post >

    Menu
    • Home
    • C
    • C++
    • Linux
    • Design Patterns
    • Programming Tips

    Popular Posts

    • 8 C++ String Functions You Must Know!
      In C++, String is one of the most used class to represent a sequence of characters. String class is an instantiation of the basic_string c...
    • How to Print Time in Particular Format in C/C++?
      You can print time in any format using strftime function in C/C++. The function declaration is as below: size_t strftime (char* buf, i...
    • 2-Minute Guide for Patching and Generating a Patch File
      Many times in the project, you need to generate a patch file or patch the file to your project. This 2 minute guide will help you how to g...
    • How to Write Better Programs in C/C++?
      I have been coding for the past 7 years in a MNC and had experienced a lot of programming rules. Here I am sharing some of the tips with w...
    • Singleton Design Pattern - My View
      I had used singleton design pattern in one of my projects. And in this post I will express my views about it. Singleton design pattern i...

    Social Share

    Weekly Posts

    • 8 C++ String Functions You Must Know!
      In C++, String is one of the most used class to represent a sequence of characters. String class is an instantiation of the basic_string c...
    • How to Print Time in Particular Format in C/C++?
      You can print time in any format using strftime function in C/C++. The function declaration is as below: size_t strftime (char* buf, i...
    • 2-Minute Guide for Patching and Generating a Patch File
      Many times in the project, you need to generate a patch file or patch the file to your project. This 2 minute guide will help you how to g...
    • How to Write Better Programs in C/C++?
      I have been coding for the past 7 years in a MNC and had experienced a lot of programming rules. Here I am sharing some of the tips with w...
    • Singleton Design Pattern - My View
      I had used singleton design pattern in one of my projects. And in this post I will express my views about it. Singleton design pattern i...

    Like us On Facebook

    Labels

    • C
    • C++
    • Design Patterns
    • linux
    • Programming Tips

    Copyright Stack Now | C, C++, Linux, Design Patterns etc 2014 . Template Created by