<p>Before you change to main, you need to run:</p>
<p><code>git stash push</code></p>
<p>in vscode - first you access the ... menu at the top of the source control window, then select stash-&gt;stash.</p>
<p>According to the <a href="https://git-scm.com/docs/git-stash" rel="nofollow noreferrer">docs</a>, this will stash away all remaining changes after the check in on the test branch.  Once you stash, you will be allowed to change over to main without vscode or git complaining.</p>
<p>When you switch back to test branch to continue your work, just run</p>
<p><code>git stash pop</code></p>
<p>In vscode, its the ... menu in the source control window, then stash-&gt;pop latest stash</p>

CC BY-SA 4.0
2021-12-27T07:15:28.797Z
we are not talking about choosing files one by one than stash from the menu right? Is it possible to only few files to merge? I mean when I merge dev to test branch, it brings all files from dev branch even though I choose to stash them one by one. what I would like to do is that simply just switch to test branch and merge only few files I want from dev branch.
hakkican
CC BY-SA 4.0
2021-12-24T23:49:40.327Z
2021-12-24T23:55:34.357Z
2021-12-24T23:55:34.357Z
Taterhead
<p>@hakkican maybe this could help</p>
<blockquote>
<p>git checkout branch_name path_file/path_folder</p>
</blockquote>
<p>then commit the changes.</p>
<p>or check this link for more explanation <a href="https://stackoverflow.com/questions/449541/how-can-i-selectively-merge-or-pick-changes-from-another-branch-in-git">https://stackoverflow.com/questions/449541/how-can-i-selectively-merge-or-pick-changes-from-another-branch-in-git</a></p>

CC BY-SA 4.0
2022-01-03T04:07:44.497Z
2022-01-03T04:07:44.497Z
Iyus Dedi Putra
<p>I started using vscode, have two branches like main and test,after finishing the work on test branch I switch to main branch and what I want to do is to merge test branch but only to commit&amp;push specific files/directories on main branch.Because I do not need to commit&amp;push all files coming from test branch.Problem is that vscode does not allow me to switch to test branch if I commit&amp;push specific files.So I have to delete the specific files I do not need on main branch and then to commit&amp;push on main branch.I want to commit&amp;push on main branch only successfully tested files coming from test branch.</p>

<github><vscode>
how can I commit and push only the files what I need while using vscode?
hakkican
# how can I commit and push only the files what I need while using vscode?

(Asked by: username_0 on 2021-12-24)

I started using vscode, have two branches like main and test,after finishing the work on test branch I switch to main branch and what I want to do is to merge test branch but only to commit&push specific files/directories on main branch.Because I do not need to commit&push all files coming from test branch.Problem is that vscode does not allow me to switch to test branch if I commit&push specific files.So I have to delete the specific files I do not need on main branch and then to commit&push on main branch.I want to commit&push on main branch only successfully tested files coming from test branch.

**Tags:** github, vscode


---

## 2 answers

### Answer by username_1 on 2021-12-24. Score: 1

Before you change to main, you need to run:

`git stash push`

in vscode - first you access the ... menu at the top of the source control window, then select stash->stash.

According to the [docs](https://git-scm.com/docs/git-stash), this will stash away all remaining changes after the check in on the test branch. Once you stash, you will be allowed to change over to main without vscode or git complaining.

When you switch back to test branch to continue your work, just run

`git stash pop`

In vscode, its the ... menu in the source control window, then stash->pop latest stash

> **Comments:**
> **username_0**: we are not talking about choosing files one by one than stash from the menu right? Is it possible to only few files to merge? I mean when I merge dev to test branch, it brings all files from dev branch even though I choose to stash them one by one. what I would like to do is that simply just switch to test branch and merge only few files I want from dev branch.  

---

### Answer by username_2 on 2022-01-03. Score: 1

@username_0 maybe this could help

> git checkout branch\_name path\_file/path\_folder

then commit the changes.

or check this link for more explanation <https://stackoverflow.com/questions/449541/how-can-i-selectively-merge-or-pick-changes-from-another-branch-in-git>


---

