-1

I am very new to git. I am working with a remote repo. I set up my my working environemnt like this:

git clone git@... /folder/
git branch -v
# origin git@... (fetch)
# origin git@ ... (push)
git branch someLocalBranch

What would I do if I want to pull changes from the remote master into my local master? And, how would I go on about pushing changes from someLocalBranch into a remote branch? That remote branch can either exist, or does not exist yet.

four-eyes
  • 10,740
  • 29
  • 111
  • 220

2 Answers2

2

your remote url is already set since you have cloned the remote repo. it's named "origin"

so to pull changes from the remote master you simply have to be on your local master branch :

git checkout master

and then :

git pull origin master

if you want to push your changes (after commiting them on your local branch) be sure you're on the someLocalBranch:

git checkout someLocalBranch

then:

git push origin someLocalBranch

it will create the remote someLocalBranch if necessary, or simply push your change if it already exist

minioim
  • 556
  • 3
  • 18
1

To pull changes from remote master to your local master, checkout master on your local

git checkout master

and then pull the diff using -

git pull origin master

To push changes from someLocalBranch, commit all your changes while you are on the branch

git commit -a -m "message for commit"

and push them to remote

git push origin someLocalBranch

Now you can raise a Pull Request from this branch to any existing in the repository. Look here for more documentation on that.

To push changes from one branch to another, try using

git push origin someLocalBranch:someRemoteBranchABC

Do take a look at detailed answer here.

Community
  • 1
  • 1
Naman
  • 27,789
  • 26
  • 218
  • 353
  • how would I push from `someLocalBranch` to a branch called `someRemoteBranchABC`. A branch with a different name! – four-eyes Dec 01 '16 at 11:01