How can I update a repo on github using git bash which is forked and after fork I have created another branch on it.
I want to update that branch.
I have create a branch locally with the aim of pushing to your remote fork.
Related
I made fork a branch of a Github repository. I made changes to my fork.
A new branch was added to the repository. I want to merge the changes from the new branch to my fork, preserving my changes to my fork.
I don't own the original repository.
How do I do this?
#add the remote to your fork.
git remote add upstream https:/github.com/whoever/whatever.git
#update your personal fork while keeping changes (swap master with the branch you want).
git pull upstream master --rebase --autostash
This should add the remote repository to your git repo (your fork) and then you tell it to fetch the changes from that branch and add your own changes on top.
In VSTS, I forked a repository to develop a separate product from the original repo.
When I make a PR from a branch into master in my forked repo, VSTS defaults to merging into the original repo. I have to be sure not to mistakenly merge into the original repo with every PR.
VSTS seems to think that I may want to merge changes from my forked repo into the original one. I have no plans to do so. How do tell VSTS to 'disconnect' my forked repo from the original?
No, there isn’t such feature in VSTS, there is the user voice that you can vote: Allow option of converting forks to repos
Work-around
As a work-around (in Visual Studio) until it's fixed:
Pull the repo.
Delete the remote repo.
Create a new remote repo with the same name.
Push the repo.
You might have to create a temporary remote repo (named temp if you'd like) in order to be able to delete the remote repo. You can delete the temporary remote repo, named "temp", after you've pushed to the new remote repo.
You'll most-likely break anything (pull requests, work items) linked to the repo and also have to re-apply any policies and security stuff.
repo = the faulty fork in VSTS.
temporary remote repo = a temporary tepo created if you cant delete the fork repo.
new remote repo = the new repo to be used instead of the fork.
It seems like one should disconnect the old remote origin and set the upstream before pushing. Maybe the push with the --set-upstream overwrites that?
Here's what I'm did:
git clone ACCOUNT#vs-ssh.visualstudio.com:v3/ACCOUNT/PROJECT/FORK-NAME NEW-NAME
git remote rm origin
Create the new repository on VSTS for NEW-NAME
git push --set-upstream ACCOUNT#vs-ssh.visualstudio.com:v3/ACCOUNT/PROJECT/NEW-NAME develop
This worked for me to change from a fork to a repo. I can see the full history and open changesets from the web viewer. I did this in Azure DevOps (formerly Visual Studio Team Services AKA VSTS). I did not test against GitHub.
Pull requests and pushes are lost. Commits are still linked
I'm not sure if you need to do the push multiple times for different branches. My fork only has a develop branch anyway. I only create a master branch so git flow doesn't complain.
I forked from main repository and cloned the forked repository on my system. I am not liking the the Github forked workflow and want to move back to normal Github Workflow.
I do not want to delete my forked repository from system and clone from Main Repository.
Is there any way to point my local setup(from forked repo) to Main repo(from which i initially forked) without cloning(fresh setup) from Main Repository?
Yes, simply replace your remote origin by your original main repo URL, using git remote:
git remote set-url origin /url/main/repo
git remote remove upstream
git for-each-ref --format='%(refname:short)' 'refs/remotes/upstream/*' |
xargs git branch -D
Then you can git fetch/git push directly from/to that main repo, and no longer to your fork.
That is provided that you own the main repo as well, and have the right to push back to it.
Don't forget that you don't have to clone a repo to make pull requests: you can make pull requests between branches of your main repo directly (share repository model).
I finished coding a website in my local computer. Now need upload it to one branch github repo. like https://github.com/xxxx/test.git branch 001
Can you tell me how to commit it in the repo branch
I have already create a local repo commit all files into it by Netbeans. So How can i push the local repo to remote repo branch?
Thanks
When you locally create a branch Git automatically takes care of creating a new branch on the remote server. Just normally do
git push
It will create the branch on the remote server.
I forked a GitHub project several days ago and from its issues, I can see that the master branch has had some modifications since.
When I cd to my location directory of this project and use git pull, it says, "Already up-to-date". Why?
How do I update my fork to include the commits from the original repo?
When you fork a repository, a copy of the original repository is established on your GitHub account. This permits read+write access to the "copy".
When the original repository resource has commits that would benefit your copy, follow these steps to update your fork's master branch. You could update other branches, but typical workflow is to update master against the original repository.
Open a Terminal
cd to your project directory
git remote add upstream <url-of-original-repository>
git branch and verify you are on master branch
git pull --rebase upstream master
Step #5 will fetch all new commits of the "original" repository, apply them to master branch from the last merge-base, then include all of your branch's commits "on top".
Any time you need to update your fork again, simply run the command in step #5.