Wednesday, November 9, 2016

Git: How to checkout a file from another git branch


1. First go to your project location using git bash

2. Use below command to go to project location:

3. Command:: cd /c/User/pritom/Git_Project/my_project

3. Now go to the branch from where you want to update file to 
current branch

3.1 You have to update the branch from which you want to 
checkout file

4. Command:: git checkout another_branch

5. Command:: git pull

6. Command:: git diff --name-only another_branch~1 
(It will list files changed last 1 commit)

7. Now go to working branch using:

8. Command:: git checkout current_branch

9. First pull to update current branch using:

10. Command:: git pull 

11. Now checkout files from another_branch using:

12. Command:: git checkout another_branch app/data/some_data.name

13. Now you file updated with another_branch

14. Command:: git status (It will show files changes)

No comments:

Post a Comment