I’ve installed a specific release version from a remote repository on Gitlab by installing the zip without cloning, I made changes and now I want to do a merge request of a new branch for my changes. but I am unable to create a new branch (locally), I guess I need to install the info or tracking data from git and add it to the file, how to do that?
Notice I am not using the command line for this, I am just looking for generic instructions.
2
Answers
You can’t. Downloading a zip file instead of cloning a Git repository is a dead-end path. Don’t do that (unless you want to stop at this dead end, of course, but in this case you do not want that).
You can recover from this mistake though. Start by forking on GitLab, and then cloning to your laptop (or whatever local computer), the repository in question, into a new location on your laptop, keeping your modified version separate from the new clone. You now have three things:
Using the clone on your laptop, check out whichever branch it was that you used to make the original zip file. Note that none of these steps need to happen inside Android Studio (which I don’t use and cannot say more about).
Now, using the command line (whose prompt I will pretend, here, is a simple dollar sign
$
), you can do this in your new clone:1The result of this
git status
should show your changes as "changes staged for commit". Usegit diff --staged
to view those changes as changes, from the command line, or re-start Android Studio in this clone if you prefer to work in an IDE. You can now make a new commit, usegit push
to send the new commit to your GitLab fork, and use GitLab to make a Merge Request.Once you are fully satisfied that your Git repository work is working the way you would like it to, it is then safe to completely remove the unzipped files you made and edited earlier. Until then, that’s acting as a backup while you get yourself started with Git.
1I assume here that you have a Linux-like system. If not, you may need to adapt the non-Git commands.
An altenrative would be to move your existing local folder, clone the repository, and import your moved local folder:
Note that with Git 2.37 (Q3 2022) and a
git branch --set-upstream my_branch origin/my_branch
, you won’t have to use-u
on your first push anymore.git push
will be enough to establish a remote tracking branch withorigin/myBranch
.