Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add new local directory to a git remote branch

Tags:

git

I have a directory on my PC I'd like to add to a particular branch in a remote git repo on my server. I have git, the branch was created fresh off the master from the server, but I've got an entire project with which I would like to use git.

What is the best way to go about this?

like image 619
Patrick Dattilio Avatar asked Feb 07 '11 01:02

Patrick Dattilio


People also ask

How do I add files to a remote branch?

Clone the remote repository on to your PC. Checkout the branch to which you would like to add those files. Move the files into your project directory, then add & commit them. git add .

Can you git add a directory?

To add a specific directory in git, you can use the git add command followed by the directory's name. Start by creating a new directory in the sample_repo. The command above will only add the specified and ignore other untracked files.


1 Answers

Clone the remote repository on to your PC.

git clone [email protected]:myproject.git

Checkout the branch to which you would like to add those files.

cd myproject

git checkout -b my_new_branch

Move the files into your project directory, then add & commit them.

git add .

git commit -m "new files for my new branch"

You'll probably want to push, too.

git push origin my_new_branch

like image 189
John Douthat Avatar answered Oct 21 '22 21:10

John Douthat