1

I have downloaded a Zip folder of Master branch from a gogs repository and after initializing git in that folder, I have added my own branch and made my own changes.

Now my question is, do I have to CLONE the project in order for adding a new branch to the repository on gogs or I can simply add my branch using this way (which is downloading zip folder) ?

1 Answers1

0

Download a zip archive of a remote Git repository (be it a gogs one, or any other remote hosting service), means downloading a snapshot view of the default HEAD.

There is no history.
The history you have created by initializing a local repository in it, and creating a branch, has no common base with the one from the original remote repository.

If you want to push back your local branch, you need first to:

  • clone the repository
  • add your local repo as a remote to the official cloned one, and fetch
  • create a new branch
  • cherry-pick from the fetched branch to the new branch (and you can cherry-pick in one command a range of commits)
  • push back the new branch (which will work, since you are pushing from an actual clone)

That is:

cd /path/to/local/repo
cd ..
git clone https://gogs/me/myRepo myClone
cd myClone
git are remote repo ../repo
git fetch repo
git switch -c newBranch
git cherry-pick repo/localBranch~n..repo/localBranch
git push -u origin newBranch

In "repo/localBranch~n", replace "n" by the number of commits you had created in your local branch.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250