I have a project which I unzipped on my local machine and now I want that project to have its own branch and additionally I want that branch to overwrite the master branch
When I unzipped the project these are the commands which I've made
git branch
returns " fatal: not a git repository
"
so this is what I did
git init
afterwards
git branch
didn't return a fatal...:
it actually didn't return anything
git remote -v
and git remote show origin
both didn't return anything
that's when I decided to do
git remote add origin https://github.com/AquaSolid/Serpent-Works
now
git remote -v
actually returned a fetch
and a push
for origin
git remote show origin
now prints all the remote branches
Now, I decided to make a new branch
git checkout -b revamped
git add -A
git commit -m "Revamped Initial..."
Now, git branch
returns just the line * revamped
which is written with green letters
I did git push origin revamped
and that's how I managed to get my revamped
branch to show on the github repo's website
>git checkout revamped
Already on 'revamped'
M .idea/workspace.xml
>git merge --strategy=ours master
merge: master - not something we can merge
>git checkout master
error: pathspec 'master' did not match any file(s) known to git.
Seems you want to contribute to the github repo ( https://github.com/AquaSolid/Serpent-Works ) in a new branch revamped
while keeping the commit history for the existing branches.
And if you want to create the branch revamped
from the master
branch, you should clone the github repo instead of download and unzip . Since you have already pushed revamped branch into github repo, you can use below steps to recreate revamped
branch from master
branch:
# In a local directory (such as an empty folder)
git clone https://github.com/AquaSolid/Serpent-Works
cd Serpent-Works
git checkout -B revamped
# Make changes and commit
git push -u origin revamped -f
Now the branch revamped
is recreated from master
branches on github.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.