Git related basic operations

Git br-a views all branches locally and remotely

Git checkout *** Switch to the local branch git push origin: the remote branch commits the local branch to the remote branch git Branch -d Local branch Delete local branch git push origin: remote branch (origin followed by a space) or git push origin –delete remote branch git reflog master View the local commit log Git checkout -b local branch name x origin/ remote branch name x git cherry-pick a commit ID // commit a commit Git remote set-url origin Git remote set-url origin git remote set-url origin

Run the following command to query the user name and email address: gitconfiguser.namegit configuser.namegit configuser. email Globaluser. name”username”git config –global user.name”username” gitconfig− GlobalUser. name”username”git $git checkout -b myRelease Origin /Release

To commit the current remote warehouse branch to another git push -u origin branch name Add remote warehouse address git remote add origin [email protected]: yuzhix/TZSCustomer git check remote warehouse address Git rm –cached $git fetch origin: The local branch ignores the files that have been stored in Git Filename This command removes a file from the Git repository and does not perform version control, but preserves the file in the workspace. Git rm means to remove a file, –cached means to remove it from the staging area. This command does not physically delete the file, but simply deletes it from the staging area. Since the file was already under version control, using this command will keep the file in the workspace, but will generate a record of deleting the file in the staging area. If you commit at this point, the file will be deleted from the repository, and if you push to the remote repository, it will also be deleted.

Git merge Git rebase is used to merge a branch into its last commit location. Git rebase is used to merge a branch into its last commit location. Git rebase abort, continue, skip

  • Git rebase abort rebase
  • Git rebase continue

If a conflict occurs during rebase, resolve the conflict by following the following steps: Git rebase continue Specifies whether this rebase will continue

  • Git rebase skip

Commits that caused a conflict here are discarded, so be careful

Rebase git reflog git reset –hard Commit number to back to

Git pull differs from git fetch + Git merge

Git has two local versions of the code base, one is the local workspace master, which usually adds and commits directly, and the other is the remote repository's local mapping code base called Origin/Master. In git fetch mode, the remote code is actually synchronized with the local origin/master, but the local workspace master is not synchronized with the remote version. Git pull allows you to merge origin/master with the latest version of the remote repository. Git pull allows you to merge origin/ Master with the latest version of the remote repositoryCopy the code

git stash

Temporarily save changes to tracked files and staging areas in the working directory without branching restrictions. You can switch back to the current branchCopy the code
  • Git stash save changes to files and staging areas are tracked in the working directory
  • git stash list

View temporary save records

  • git stash pop

Restores the last temporary save

To be continued, to be updated…

Author: Li Enlin, Large front End R&D Center