How do I push changes I made in a branch into the master branch?

There is no remote repository.

There only exist one repository on my local machine.

So here is what I did:

git branch new-branch
git checkout new-branch

//implemented some changes

//now wants to push changes to master
//what is the command?

Upvotes: 0

Views: 4498

Answers (3)

yashi ajmera
yashi ajmera

Reputation: 36

As I Understand, what you are trying to do is "merge" your branch with master. so try the following.

git branch new-branch
git checkout new-branch

//implemented some changes

//to push chages to master first checkout to master
git checkout master
git merge new-branch

Upvotes: 2

Marc K
Marc K

Reputation: 271

You're merging your commit to master, not pushing it. Pushing is for sending your local changes to a remote.

git branch new-branch  #creates a new branch
git checkout new-branch #switches to the new branch

# implemented some changes
git add somefile #stages your changes for next commit
git commit -m "implemented some changes" #commits those changes with message

# push* (it's merge) changes to master
git checkout master #switches back to master branch
git merge new-branch #merges your changes from new-branch back into master

See https://git-scm.com/docs/git-merge for more info.

Upvotes: 0

Mark Adelsberger
Mark Adelsberger

Reputation: 45759

It may sound like I'm nitpicking here, but in git (and therefore in the git documentation) what you're saying you want to do is not what "push" means.

What you're trying to do is "merge" your changes into the master branch. Please refer to the git merge documentation for an explanation of the basics. https://git-scm.com/docs/git-merge

Upvotes: 1

Related Questions