IIT Roorkee has a detailed process for students who wish to change their branch.
Here is a summary of the main rules:
Students who have enrolled in B.Tech, IDD, and IMD programs with admission through JEE Advanced are eligible for branch change at the end of the first semester. But you must fulfill the following criteria:
The strength of a class shouldn't increase by 5% of the actual number of seats
Branch change is strictly done on the basis of merit, that is CGPA. In the case of a tie, JEE ranks are considered. Basically, you have to be among the toppers in your branch to be eligible for branch change as the competition is tough, especially in preferred branches like CS and ECE.