New branch locally for Function Development

Suppose you currently xx in your local branch, execution

Branch xxxy git , namely the establishment of a local branch xxxy. Note that this is only in your local branch if you do not submit to the distal end of the branch, only you see. At this time, the new branch of the same content xx branch of your current location,
based on your current location as a branch of the template.

Then, git branch can see all your local branch.

Then, Git checkout XXXY, switch to the current branch.

(In fact, the only branch of creation and the need to switch one of the following instruction can be completed: git  checkout -b 分支名)
( Git Checkout branch name   after executing your local data directory structure, automatically updated with the contents of the branch !!! handy! However, if you add a file, do not add the words, git will not move him)

Then, you can modify the code, add files and so on, then, git add, git commit will save the changes to a local Repository.

 

 

note:

Suppose now that there is a local branch xxx1, which corresponds to the distal end of the branch yyy1 repository, you are in the current branch xxx1 locally, and perform Git Branch xxx2, to establish a new basis xxx1 xxx2 branch points locally, and then switch to the branch xxx2, after an attempt to free to modify the code, modify, add, and must commit, or else, when you cut back to the local xxx1: git check out xxx1, you will get an error:

 

A scenario:

The current in the local branch x, xx corresponding to the remote branch, inadvertently modified the code, and then want to save changes to a local part of the code that a new branch in xNew (not want to save to the distal end), the operation required : in x branch, execute git add, git commit, then, git branch xNew, git checkout xNew the future you will be able to see xNew branch code. In addition, the code in the local branch of x added not want to keep, cut the branch to x, and then do git reset -hard HARD ~ 1 (back to before the most recent commit, and at the same time update the local content of the document, ref: HTTPS: // the WWW .cnblogs.com / lfxiao / the p-/ 9378763.html )

 

Remember that a principle:

After the local branch changes the current file, if you want to save, then be sure to add, commit, if we are not out to save the reset! Then, and then switch to another branch! (Add commit instruction execution is telling git file system, right now there are changes! If you do not perform, git does not know it)

 

 

Ref:

https://www.cnblogs.com/videring/articles/6962005.html

Guess you like

Origin www.cnblogs.com/butterflybay/p/11272412.html