This is intended as a question that I answer for other people's benefit. However, if someone answers this question before I finish my research, I would be grateful.
How do I, from the shell, branch an existing git repo (which I have developer access to), edit it, commit those changes then push it to the server for review before being merged.
EDIT
Please note that this is not my project, but someone else's. This use has given me access to do some work. When done, I will request that they merge the changes back to the original
In order to create a Git branch from a commit, use the “git checkout” command with the “-b” option and specify the branch name as well as the commit to create your branch from. Alternatively, you can use the “git branch” command with the branch name and the commit SHA for the new branch.
Create a new branch with the branch, switch or checkout commands. Perform a git push with the –set-upstream option to set the remote repo for the new branch. Continue to perform Git commits locally on the new branch. Simply use a git push origin command on subsequent pushes of the new branch to the remote repo.
For setting up your repo, you will need to follow these instructions. Then you will need to clone/fork the existing repo like this.
Then make your changes. Once you are done making your changes. You will need to make a "commit" that looks like this
git commit -m "I changed something somewhere"
Then you will want to pull down any changes from the repo that may have been pushed while you were working.
git pull origin master // master being the branch that you cloned/forked
Once the pull is completed with no conflicts, you may push your changes up.
git push origin master // this is saying that you want to replace the remote master branch with your local master branch
EDIT To push to a repo without overwriting the master, do this:
git clone //clone what branch you want
git checkout -b new_branch //this will create a new local branch
git push origin new_branch //this will create a new origin branch
If I understand your question correctly:
This is actually a perfectly normal situation, here's what to do:
On GitLab, fork the project: this creates a clone of the original repository in your personal workspace. The point is that you can push to your personal workspace.
On your PC, clone from your fork, not the original.
Create a branch (git checkout -b myfeature
), make the changes and commit, then push this branch to your fork (git push -u origin HEAD
)
On GitLab, visit your fork's page, and near the top there should be a button offering you to create a Merge Request from the branch that you pushed just now. Click on it, review the changes, if it looks good, then set an assignee and click Create. The assignee should receive an email notification
You don't need write access to a project to be able to contribute.
All your write operations are on your workspace on GitLab and on your local PC.
Reviewers of your Merge Request can accept it or reject as they wish.
They can also ask that you make improvements, which you can implement and push (simple git push
after your local commits), that updates the merge request (reviewers can reload the page in the browser and see your changes).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With