Home > Back-end >  Pushing and merging changes on continuously updating project
Pushing and merging changes on continuously updating project

Time:01-14

I am working on project which I have cloned from main repository branch . Now I want to push changes to a new branch( i will create new branch for me only) and then raise merge request to main branch. The problem i am facing is that project main branch is being updated continuously so for that I have used git pull command but that does not shows any changes which are on remote when I open that on vs code i am getting the same code which was available when I first cloned the repository.

Now there are chances that I will change some code in same file which was updated in main branch and i may know about the changes then what will be the best way for me to push and check changes

I used git pull command and i thought I will get new code when open that in vs code but that was old code

CodePudding user response:

I used git pull command and i thought I will get new code when open that in vs code but that was old code

As you said in your question for main to have the changes in your feature_branch you need to raise a merge request (aka pull request). When trying to keep your branch up to date with changes in main you also need to merge.

There are two ways to achieve it:

  1. via pull & merge:
    1. checkout main,
    2. pull
    3. checkout feature_branch
    4. merge main (which now has the changes made by others)
  2. via fetch & merge
    1. fetch origin main -> this downloads changes made by others to a local branch origin/main (but main [no origin/] doesn't get the changes)
    2. merge origin/main (not merge main)

You can find the steps in How to take latest changes from dev branch to my current branch.


You could pull the remote main into feature not via main/origin/main but that would sooner or later end up in a mess - this way is only for advanced use cases and users.

CodePudding user response:

first we use ---> git checkout {your branch name} for go to your branch after that you will do any changes Here and then git push origin {your branch name} which is used to push the changes on this branch not reflect your main branch. you have not used to git pull simply use git checkout {your branch name} to see changes on main branch or your branch.

  • Related