Git Git


Git Workflow

  • Workspace: indicates the local working directory
  • Index: cache area to temporarily store local changes
  • Local Repository: A local repository that only wants to commit the HEAD one last time
  • A: Remote repository

Git Git

  • Git local branch management

    • View, switch, create, and delete branches

    • Git br -r #

    • Git br <new_branch

    • Git git git git git

    • Git br –merged # Look at branches that have been merged into the current branch

    • Git br –no-merged # Look at branches that have not been merged into the current branch

    • Git co # switch to a branch

    • Git co-b <new_branch> # create a new branch and switch over

    • Git co -b <new_branch

    • Git co $id # git co $id # Git co $id # Git co $id #

    • Git co $id -b <new_branch

    • Git git git git git git git

    • Git git git git git git git git

  • Branch merge and Rebase

    • Git merge # Merge branch into current branch

    • Git merge origin/master –no-ff #

    • Git co && git co master && git co master && git merge

  • Git patch management (easy to use when developing synchronization on multiple machines)

    • git diff > .. /sync.patch # Generate a patch

    • git apply .. /sync.patch

    • git apply –check .. /sync.patch # Test whether the patch is successful

  • Git staging management

    • Git stash #

    • Git stash list

    • Git Stash Apply # Restore temporary content

    • Git stash drop #

  • Git remote branch management

    • Git pull # Grab all branch updates from the remote repository and merge them locally

    • Git pull –no-ff # grab all branch updates from the remote repository and merge them locally

    • Git fetch Origin

    • Git merge origin/master

    • Git co –track origin/branch

    • Git co-b <local_branch> origin/<remote_branch

    • Git push # push all branches

    • Git push origin master # git push origin master

    • Git push -u origin master git push -u origin master

    • Git push origin <local_branch

    • Git push origin <local_branch>:<remote_branch

    • Git origin :<remote_branch

  • Git remote repository management

    • Git remote -v

    • Git remote show origin

    • Git remote add origin git @github

    • Git remote rm # git remote rm #

  • Creating a remote repository

    • Git clone –bare robbin_site

    • SCP -r my_project.git [email protected] :~ #

    • Mkdir robbin_site.git && CD robbin_site.git && git –bare init

    • Git remote add origin git @github.com

    • Git push -u origin master #

    • Git push -u Origin Develop # Commit the local Develop branch to the remote Develop branch for the first time, and track

    • Git remote set-head origin master

    • git branch –set-upstream master origin/master

    • git branch –set-upstream develop origin/develop

  • View, add, submit, delete, retrieve, reset and modify files

    • Git help #

    • Git show $id git show $id

    • Git co —

    • Git co

    • Git add # commits the working file changes to the local staging area

    • Git add. # Commit all modified working files to the staging area

    • Git rm # delete files from the repository

    • Git rm –cached # Delete files from the repository without deleting them

    • Git reset # Restore from staging to working files

    • Git reset –. # Restore from staging to working files

    • Git reset –hard # Restore the status of the last commit

    • Git ci. Git ci

    • Git ci –amend # Amend the last commit record

    • Git revert <$ID > # Restores the status of a commit. The restore action creates the commit itself

    • Git Revert HEAD # Restores the status of the last commit

  • Look at the file diff

    • Git diff # Git diff # git diff

    • Git diff # compares the difference between two commits

    • git diff .. # Compare between two branches

    • Git diff — Staged comparisons between staging areas and version libraries

    • Git diff –cached # Compare staging and version library differences

    • Git diff –stat # only compares statistics

  • Viewing the Submission Record

    • Git log git log

    • Git log -p # see diff for each detailed change

    • Git log-p-2

    • Git log –stat #