Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

HowTo | Git and GitHub

ML-TANGO edited this pageOct 29, 2022 ·1 revision

Git, GitHub KB

Git Checkout Use Case ExampleYou are working on a branch calledfeature/A containing a file namedutils.js.You have another branch calledfeature/B with anupdatedutils.js file.

You want to checkout that file and bring it from the branch calledfeature/B to the branch calledfeature/A.

Solution 1: Use thegit checkout command

Thegit checkout command offers a simple way to get a file or a folder from another branch.

Here is the syntax to checkout a file from another branch:

git checkout <other-branch-name> -- path/to/your/folder

Here is the process to follow:

  1. Checkout to the branch where you want to copy the file.
git checkout feature/A
  1. Once you are on the correct branch, copy the file.
git checkout feature/B -- utils.js
  1. Use thegit status command to ensure that the file has been copied.

  2. Commit and push to a remote.

When using the checkout command, you can also get:

  • A folder from another branch.
  • Multiple files by specifying each one of them.

Also, note that you can get a file/folder from the stash.

👉Note

  • This page might contain some wide rendered images. If you want to see the whole contents with wider page, please useWide GitHub extension of Chrome.
  • If you are experiencing the error on rendered images due to the low-bandwith Internet delay, please use F5 function key for refreshing current page.
Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp