I have an issue understanding the work flow on GitHub.
First I fork someones repository.
I clone the repository locally( on my computer)
I create a branch called Sample101 and make changes
I push branch Sample101 to my GitHub account
I create a pull request
The person I created a pull request Merges Sample101 Branch to his Master Branch.
The question is, How do I update my forked/clone after that person merges/updates his master branch? I just want my master copy to be up to date.
In your local repository cloned from your Github repository (which is the fork you have push rights), add the remote for the original repository
git remote add upstream <original remote url>
Now pull, or fetch merge, whichever you're more comfortable with
git checkout master
git pull upstream master
Now push up to your fork
git push origin master
Related
I have a github repository called A. It's connected to heroku-A and the website is up and running. I did changes locally to the code, but I don't want those changes to show on repository A or heroku-A. I want to push the code to a totally new repo. How can I do this?
Here would be the procedure:
Create a new git branch (so that code is separate from your other repo)
git checkout -b <new_branch>
Add a remote pointing to your new repository
git remote add <new_repository_url> <new_repository_name>
Push the new branch to the new repository:
git push <new_repository_name> <new_branch>
I have two branches in bitbucket and I want to push only some commits (which are approved by me) from one branch to another branch which is a master branch.
Can someone explain to me how I can do it in the bitbucket environment?
Thanks in advance.
you can use git cherry-pick
steps
1. git log
this will list all commits take the commit id which you wanted to move.
2. git cherry-pick <commit-id>
apply this after switching to master branch
3.then push new master to remote
git push <REMOTENAME> <BRANCHNAME>
eg. git push origin master
or
git push <REMOTENAME> <LOCALBRANCHNAME>:<REMOTEBRANCHNAME>
eg:
if my remote name is heroku and i want to push local heroku branch to heroku(remote) master barnch(heroku/master)
git push heroku heroku:maste
links
What does cherry-picking a commit with git mean?
I created a new repository on github, modified the default readme file and then created a development branch to work on my project.
I have successfully commited and merged on development branch after it, sending all local modifications to github.
But when I try to push my local modifications to the master branch, XCode returns the following message:
The local repository is out of date
Make sure all changes have been pulled from the remote repository and try again.
And if I try to pull the changes..
How can I correctly push my project to the master branch?
You must do a git pull before you push to the server.
There are updates on the serer which you don't have on your repository.
git pull origin <branch
git push origin <branch>
When you try to push git verify that the latest commit from the server is in your local branch. if it does not - if you don't have it locally yo will be asked to pull the changes form the server before you can push your updates.
simple example,
1)made a new project
rails new test_app
2) git commands
git init
git add .
git commit -m "init"
git push origin master
ok finished!
now after this, if i look at github.com webpage gui.
it doesn't show my repository.
How can i set this to my github webpage?
First of all you need to create an repository on github. After that you need to create an ssh key with github for your pc. Befor you can push to the master branch you need to add the remote repository:
git remote add origin git#github.com:yourrepo.git
Than push "origin" to the master branch.
I'm trying to update the 3-2-stable branch on my fork of the Ruby on Rails project. So after cloning rails, I initially did a git checkout -b my_branch remotes/origin/3-2-stable. Then I made my changes. Then I added my fork as a remote repository with git remote add my_fork git#github.com:myusername/rails.git. Does a git push my_fork my_branch update the 3-2-stable branch only in my_fork? Is there something special I need to do?
Does a git push my_fork my_branch update the 3-2-stable branch only in my_fork?
Yes it will. It won't affect any other repo.
Note that the 3-2-stable on your fork won't be impacted either: a new branch my_branch will be created on your fork to reflect your local branch.
But if you want to push/pull that branch from the repo my_fork, then this would make it easier:
git push -u my_fork my_branch
See "What exactly does the “u” do? “git push -u origin master” vs “git push origin master”" for more on setting the upstream branch of a local branch.