Git a piece. Basic Operation __git Operation

Source: Internet
Author: User
Tags diff git clone

Command-line operations (because they are normal users under the Linux command line, they operate at the $ level):

I. Native configuration Add user
git config–global user.name "XX"
git config–gloaba user.email "XX@163.com" View git configuration and user information
git config–list generates SSH secret key (2 ways: 1.git GUI graphical interface operation; 2.git command, that is, the following process)
1 See if there is a secret key, then back up and then delete the folder
CD ~/.ssh
Ls
2) Formal generation, input instructions and then press three times enter, that is, the third time enter the fingerprint password input can be empty
Ssh-keygen-t rsa-c "Mailbox"
3) Add private key to SSH (if the fingerprint password is configured to enter validation)
Ssh-add Id_rsa into the computer System User folder, locate the Id_rsa.pub, and turn on the setting SSH keys copied to GitHub (
The Web server can add multiple SSH key public keys to test whether the computer has access to GitHub permissions
SSH git@github.com

Two. Upload GitHub ssh, start to build both ends of the repository (version library, warehouse) and associated.

Establish the process (2 ways): Create a new-> locally and then add to the remote side (specific steps):
Git init->git Remote Add Origin git@xxx-> add some initial files to the warehouse xx->
git add xx->git status->git commit-m "Initialize warehouse"->git status->git commit-a-> Write your code->
Modify files submitted before->git diff xx-> Resolve conflicts submit git clone XX clone warehouse The following are only actions such as creating workspaces locally
CD D:
CD Git
mkdir Firstprogram
CD Firstprogram
PWD (means to view the full path to the current working directory)
Git init (this directory becomes a repository that git can manage, complete this step to git directly to remote add)
git add readme.txt (added to registers)
Git status (red Alert when uncommitted)
git commit-m ' comment description at time of submission '
Git status (green reminders appear after submission)
Git commit-a (automatically update changed files, auto)
git diff readme.txt (used to view the comparison before and after the modification, used when modified)
git log (view submission history, Reverse record: Information includes submission version number, author, time, submission content)
Git log–pretty=oneline (view history briefly, each change appears on one line)
Git Reset–hard head^ (back to 1 versions of the current version)
Git Reset–hard head^^ (back to 1 versions of the current version)
Git Reset–hard head~100 (back to 100 versions of the current version)
Git Checkout–readme.txt (will undo the changes but not yet added to the buffer stage content)
Git reflog
Git reset-hard version number
View Content
Cat Readme.txt
deleting files
RM b.txt
git remote rm xxx (delete the remoted warehouse xxx, for example, origin is a remote warehouse < URL address > alias)
git push-u sie-remote Master (submits the local file to the GitHub Sie-remote version Library < or origin, the version library name >. The local change was updated to the GitHub service at this time. Master is the meaning of the branch
Branch creation
Git branch (displays the current branch, such as: Master)
Git branch sie-branch (create Branch)
git checkout sie-branch (switch to New branch)
Create a new branch from an existing branch (for example, from the Master branch) and create a dev (develop) branch (equivalent to a replication branch)
git checkout-b Dev
To push the branch to the distal branch –> you can see that the distal branch is a push.
VI page_cache.inc.php
git add page_cache.inc.php
Git commit-a-M "added initial version of page cache"
Git push Origin Sie-branch (commits the branch to the remote server, just submits the branch structure and content to the remote, and does not take place with the backbone of the merge behavior)
Another push branch, if it is under the current Loc-dev branch, you can write only git push
Git push Origin Loc-dev:remote-branch-dev
Branch Pull
Git pull Origin Dev
Or:
Run git fetch (if the local and remote is already associated), you can get the remote branch information to the local,
You can then run git checkout-b loc-v2 origin/remote-branch-v2 to map a remote branch to a branch of the local named Loc-v2
Local branch Merge
git checkout master (switch to new backbone)
Git merge sie-branch (merge branches to backbone)
Remote Branch Merge (more than one remote address and one backslash/)
git merge origin/b
Git branch (show current branch is master)
git push (Sie-branch code is also merged in the backbone at this time)
Conflict resolution (Updated upstream and = = between the content is pull down, if you do not need to delete, you can delete the local line)
Git stash (staging local content)
Git pull
git stash pop stash@{0}{stash@{0} modify the tag to restore the staging content}
Delete Branch (provided that the branch being deleted is not the current branch, otherwise it cannot be deleted)
git pull Origin–delete Dev
Another way to delete a branch
Git push origin:d Ev
Eliminate tracing for Master branch
Set the specified branch
Git Branch–set-upstream-to=origin/dev
To cancel tracking of master
Git Branch–unset-upstream Master

Three. Conceptual analysis

Workspace: Typically the project area or module area (also equivalent to the Android Studio project name root), but below the workspace
Hide folders. Git is not part of the workspace
Version Gallery: is a. git directory. There are a lot of things in the version library, the most important of which is the stage (staging area), and Git automatically creates the first branch master for us and a pointer head to master.

Four. Other operations

1. Show all remote warehouses
git Remote-v
Origin git@search.ued.taobao.net:projects/search.git (fetch)
Origin Git@searc H.ued.taobao.net:projects/search.git (push)
GitHub git@github.com:yyfrankyy/search.git (fetch)
GitHub Git@github.com:yyfrankyy/search.git (push)
2. Rename remote warehouse
git sqlremote rename github gh
git remote
Origin
GH
3. Delete remote warehouse
git sqlremote rm github
git remote
Origin
4. Crawl data from remote warehouse, update local warehouse:
$: Git fetch origin
Remote:counting objects:58, done.
remote:compressing objects:100% (41/41), done.
Remote:total (Delta), reused 1 (Delta 0)
Unpacking objects:100% (44/44), done.
from Git://search.ued.taobao.net:projects/search.git
* [New branch] Product-> origin/product
5. View Remote Warehouse Letter Can be used to track someone else's push:
git remote show Origin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.