git command daily work summary


Common command git
git commit -m "fix: Problem Description # CM-jiro number of problems" such as submitting a record describes a template: fix (admin / statistics / companies to pay): "Export all user information" click unresponsive # CM-31334

git branch -r View all remote branch
git branch -a view of all local and remote branch
git branch -a view the remote branch (the current branch, the branch at the same level, on a branch under a branch, sub-branch can not see the other branches of )
git branch -a | grep CM-30554
git tag tag to view the remote branch
git clone
git the Add
git the Add -i
git the commit -m
git the Push
git Checkout
git pull
git log
git log --oneline --graph view the different branches of historical submitted route
RESET Git
Git Revert
gitk
gitk --all
Git rebase the
two were combined before the commit record git rebase -i head ~~ default, the combined use git push -f forces the combined local commit record to a remote repository pushed to change the remote repository submit records

git rebase -i head ~ 2 2 represent the first two records and submitted and
git Merge
git FETCH updates the index (see the remote branch, found that the command is executed when you do not see the target branch)

git stash staging modified files will all uncommitted changes (including staging and non-staging of) are saved, sometimes rebase failed because there is file uncommitted so the first use git stash hidden modified files in rebase

And modifying the code before submitting the best git pull --rebase to pull down the latest code and merge, if a conflict would be resolved before the conflict
git pull --rebase default remote branch will pull down the current branch and merge with the current branch
git pull --rebase origin CM-22901 pull the latest code and CM-22901 branches merge with the current branch

git stash pop to recover the temporary modified files

Case in point: Note the difference between --soft --hard --mixed
1. Local modify a bunch of files (do not use git add to the staging area) and want to discard the changes.
Individual files / folders: git Checkout - filename
git Checkout - Test.java
all files / folders: git checkout.


2. Local modify / add a bunch of documents, has been git add to the staging area, to discard the changes. 
Individual files / folders: git reset HEAD filename (note the git reset HEAD ^ are not the same)
for all files / folders: git reset HEAD.


3, after passing through the local git add & git commit, wants to revoke the the commit
(1) git reset --mixed (equivalent to git reset ie with no parameters, modify the code unchanged, then you need to re-add the commit)
# rollback All content on one version 
git the RESET the HEAD ^ (git the RESET --mixed the HEAD ^) 
# fall back to a version of the RESET commit_id git
git the RESET 057d (git the RESET --mixed 057d) #
a.py fallback version of this document to the previous version, then git add a.py can (only --mixed to roll back individual files)
git the HEAD ^ a.py the RESET (the RESET --mixed the HEAD git ^ a.py)


(2) git reset --soft (same code changes, do not need to re-add only the commit)
# forward to fall back to the first three versions of 
git the RESET --soft the HEAD ~ 3 
git the RESET --soft head ^^^ 


(3) git reset --hard (fallback code changes, need to re-add and then commit re-modify the code before you change the code will disappear, caution)
# fall back to the local and remote state like 
git reset - Origin -hard / Master 
# roll back the state of the local version of a state
Git RESET --hard e74705
Git --hard head RESET ~. 1
Git --hard head RESET ^
(note: head equivalent to the head ~ 0)


4, Revert git
git commit once the HEAD Revert (fall back to the previous commit) before the revocation of
a pre-commit before git revert HEAD ^ withdrawal (fall back on two commits)
git Revert commit (for example: fa042ce57ebbe5bb9c8db709f719cec2c58ee7ff) revocation of the specified version, as will be withdrawn once submitted for preservation.

Remote submission fall back once (before the commit will be deleted)
1, git the RESET -hard target version
rollback local commit
git reset -hard e74705c6c09160ff66d6900cd4fa468d30e30fe7
then you need to submit compulsory cover remote
git push -f
applicable scene: If you want to restore submitted to a previous version and the version submitted after the release we are not, you can use this method to submit records will be reset after the target version is deleted


2, git revert -n target version number (before the commit will be retained)
fallback local commit (actually a copy e74705c6c09160ff66d6900cd4fa468d30e30fe7 version of the submission)
git Revert -n e74705c6c09160ff66d6900cd4fa468d30e30fe7
commit the local modification
git commit -m "fix (archadm) : bug fix "
submitted to local modifications to change the remote branch
git push
applicable scene: record submitted after revert after the target version will not be deleted

Modifying Remote commit record:
1, modify the local commit record 
git commit --amend 
then forced to submit to a remote branch
Git -f Push the CM-31499 Origin-FIX
2, modify the remote commit log information submitted
git rebase -i head ~ 1
to edit r modify
git push -f

删除本地分支
git branch -d ECM-953
warning: deleting branch 'ECM-953' that has been merged to
'refs/remotes/origin/ECM-953', but not yet merged to HEAD.
Deleted branch ECM-953 (was 82dd516).

Delete remote branch:
in front of the colon space no less, the principle is to push an empty branch onto the server, equivalent to remove the branch
git push origin: ECM-953
can also be used to change the command to completely remove branches
git push origin --delete ECM- 953

git combined branch changes to the document section devyaomy current branch
git checkout --path devyaomy file
such as: git checkout --patch ECM-953 src / main / java / cma / antispam / ListVirusMailAction.java

git cherry-pick used to commit another local branch of modifications to the current branch (submitted that commit again to the current branch), the command may checkout --path convenient than git
git cherry-pick [--edit] [ -n | --no-the commit] [-m parent-Number The] [-s] [-x] [--ff] [-S [<keyid>]] <the commit> ...
--edit, the Message edit the commit
-n , --no-commit, just apply these commits to change, but do not submit to the current branch on the current branch

git cherry-pick --continue | --quit | --abort

如 git cherry-pick -n b872d926bed4a90631ecb4cd937616ad492b5bc7

 

View commit content
submitted recently recorded a
git log -n 1 (1 digital)
last commit all changed files
git log -n 1 --stat
submit all details of the most recent changes to the
git log -n 1 -p

How to upload commands to a local project to git
1, (first enter the project folder) by this command git init git directory can become a warehouse management
git init
2, to add files to the repository, use the command git add. Add staging area to go inside, do not forget after the decimal point ".", which means adding all the files in the folder
git the Add.
3, using git commit command tells Git, the submission of documents to the repository. Quotes to commit
git the commit -m 'First the commit'
4, related to the remote repository
git remote add origin of your remote database address
as:
git remote add origin https://github.com/cade8800/ionic-demo.git
5 obtaining remote database synchronization with local merger (if remote library does not have to do this step is empty, otherwise the back of the submission will fail)
git pull --rebase Origin Master
6, the contents of the local repository pushed to the remote, use the git push command, in fact the current push to the remote master branch. After executing this command you will be asked to enter a user name, password, after verification by start uploading.
Origin Master the Push -u git
7, state inquiry command
git status

Other Reference Site
http://www.cnblogs.com/tugenhua0707/p/4050072.html

 

Guess you like

Origin www.cnblogs.com/zwyu/p/11664814.html