New and git merge

. Look at the git command: 1 Check local branch git branch; view remote branch git branch -r; switching branch git checkout -b agrochemical origin / agrochemical; see git branch -a branch belongs; rollback command: $ git reset - -hard HEAD ^; fall back to the previous version $ git reset --hard HEAD ~ 3; fall back before submitting the first three times, and so on; fall back n times before submitting $ git reset --hard commit_id; retreated / sha into the code specified commit $ git checkout commit ID; see submission records: $ git log; strong push to the remote: $ git push origin HEAD --force

2.git delete the remote repository files, using the git rm command can be, there are two options: one is to git rm --cached "File Path", do not delete the physical file, only the file is deleted from the cache; one kind is git rm --f "file path", not only delete the file from the cache, but also deletes the physical file (do not recover to the trash). If you have not accidentally commit files to the server you want to remove it, you can use: git rm - cached "Path + file name"; git push;; git commit -m "delete file" git rm -r "path + file name "; git commit -m" delete file "; git push

The next step is get down to business, you have to use at work: First, create a branch and switch 1, create a new branch and switching to the branch to commit First, we start with the most simple to below demonstrates git branch Create basic operation and switched, the following steps: 1 "git branch <branch name>: first using git branch bugfix01, creates a new branch of bugfix01 current branch is named the master branch. 2 "git checkout <branch name>: then use git checkout bugfix01 command to switch to the new branch bugfix01 of our newly created. 3 "git commit: git commit command last used code to submit on the new branch.

2. Create and switch branches 1 "git checkout -b <branch name>: the first to use git checkout -b bugfix02 command to create a new branch in the branch currently located bugfix01 and switch to the newly created bugfix02. 2 "git commit: git commit Then you can use submit a new branch in the bugfix02.
Second, the branch merged with the deletion and conflict resolution 1, branch consolidation -merge first use git checkout master command to switch to the master branch. Then use git merge bugfix01 command bugfix01 branch changes fit into the master branch, to commit the new file after the successful combination will fit in, at the moment there will be a new commit number, it corresponds to the bottom of the C9 . Then git merge bugfix02, in the modified bugfix02 bonded into the master branch, merge commit number corresponding C10. Finally, it can still be submitted in the normal master branch.
2, remove the branches above you can see, although bugfix01 and bugfix02 branch has been pushed into the master branch, but these two branches is still there. If we do these two branches of the pointer, two pointers can be deleted branches: the first to use git branch -d bugfix01 branch bugfix01 be deleted. Then delete the branch bugfix02 use git branch -d bugfix02. Delete pointer operational point of view to just remove branches pointing to the number of commit, and does not remove its related submission number, commit the previous record can still be found in the log, you can still create a new branch on the commit. If you want to delete the remote branch, then you have to use $ git push origin --delete <branch name> a.

Guess you like

Origin www.cnblogs.com/caozhengze/p/11811699.html