简体   繁体   中英

Need advise about working with remote git repo

I have git situation like below and im new to git too :

  • On remote we have Development branch and i have cloned it
  • I have checkout Development and create new Branch called A01
  • I have done Push the branch A01 and create Pull Request on A01
  • A01 reviewed and merge to remote Development repo
  • I do made some changes in Projects file but for local environment only (not pushed)

What should i do if i have to create new branch (ex:A02) to implement new feature In my thinking there are 2 options :

  • Merge local Development br with A01 br
  • Git pull for Development branch(remote) (but when i do this, some msg showing : The pull would overwrite your local changes to the following 2 files ... )

Please advise, appreciate your help.

I do made some changes in Projects file but for local environment only (not pushed)

What you need to do depends on what you want to do with your local changes.

You don't want your local changes to be part of any remote branch.

  • Do git stash . This will clear your working tree and index tree in your repo
  • Do git pull . It should complete successfully.
  • At later point, when you want these changes back you can do git stash apply . Remember, you might get merge conflict while applying it back. You need to resolve them.

You want your local changes to be part of develop branch (remote as well) immediately

  • Stage and commit your local changes.
  • Then execute git pull . You might get merge conflict, you need to resolve them.

You want your local changes to be part of remote branch but not for now.

One option is to create a new branch to track your local changes.

  • Run, git checkout -b <new branch name>
  • git checkout develop
  • git pull
  • Later when you want to work on your local changes, you can do git checkout <new branch name>

Another option,

  • you can commit your changes to local develop branch.
  • you can create A02 out of remote branch directly as git checkout -b A02 origin/develop (Assuming your remote repo name uses the default name, origin.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM