Reputation: 749
Git has been introduced on a project, after I've been working on it for a bit.
Now there's a local git server, which hosts the base code, I've been working with and modified.
Now I need to create a new branch on the server, which features the modifications I made.
My plan is to pull(?) the current git repository to a new folder, copy over all the content - which I've been managing locally, then create a new branch locally and push(?) it again onto the server.
This would leave me with a new branch, which I can modify locally and push onto the branch on the server, is that correct?
mkdir project_git && cd project_git
git pull <remote>
git checkout -b my_changes
cp project project_git
git add -A
git commit -m "new branch with local changes"
git push origin my_changes
Is this the "correct" way to handle the situation? What commands would I need to use for this?
Upvotes: 0
Views: 2398
Reputation: 1217
Git locally stores all modifications of all branches, and there is only one folder which is your current working space.
When you checkout a branch, your files are modified to the choosed branch state.
When you clone your repo, this unique folder is created, and you don't need to create another folder.
You can do this steps to push your changes on remote repo :
git pull <remote>
git checkout -b my_changes
# Do all your changes
git commit -a -m "There are my changes"
git push <remote> my_changes
This will create a branch called "my_changes" on remote repo
Upvotes: 1
Reputation: 38136
Creating a new branch for git server, you can clone
the repo in another directory (if you have local repo, you can pull
directly), and switch to a new branch locally and finally push
to the git server. Detail steps as below:
# In another directory
git clone /path/for/git/server
cd repo
git checkout -b newBranch
# make changes
git add .
git commit -m "message"
git push origin newBranch
Upvotes: 1