github and git, base operation

one

1. After installing git, set up global users and mailboxes

$ git config--globaluser.name"Your Name"
$ git config--globaluser.email"[email protected]"

2. Then we need to configure SSH

2.1. Create SSH Key
$ ssh-keygen-trsa-C"[email protected]"


Log in to GitHub and open "Account settings"

3. Associate the remote address
$ git remote add origin git @ github . com : cqcre / cqc . After git is added, the name of the remote library is , this is the default name of Git, and it can be changed to something else, but this name is a remote library at a glance .
originorigin

4. Push information

$ git push-uorigin master

$ ssh-keygen-trsa-C"[email protected]"

$ ssh-keygen-trsa-C"[email protected]"

$ git push-uorigin master

Git common operation commands:

1) Remote warehouse related commands

Checkout the repository: $ git clone git://github.com/jquery/jquery.git

View the remote repository: $ git remote -v

Add a remote repository: $ git remote add [name] [url]

Delete remote repository: $ git remote rm [name]

Modify the remote repository: $ git remote set-url --push [name] [newUrl]

Pull remote repository: $ git pull [remoteName] [localBranchName]

Push remote repository: $ git push [remoteName] [localBranchName]

 

*If you want to submit a local branch test to the remote warehouse and use it as the master branch of the remote warehouse, or as another branch named test, as follows:

$git push origin test:master // Submit the local test branch as the remote master branch

$git push origin test:test // Submit the local test branch as the remote test branch

 

2) Branch operation related commands

View local branches: $ git branch

View remote branches: $ git branch -r

Create a local branch: $ git branch [name] ---- Note that the new branch will not automatically switch to the current branch after it is created

Switch branches: $ git checkout [name]

Create a new branch and switch to the new branch immediately: $ git checkout -b [name]

Delete branch: $ git branch -d [name] ---- The -d option can only delete the branch that has participated in the merge, and cannot be deleted for the branch that has not been merged. If you want to force delete a branch, you can use the -D option

Merge branches: $ git merge [name] ---- Merge the branch named [name] with the current branch

Create remote branch (local branch push to remote): $ git push origin [name]

Delete remote branch: $ git push origin :heads/[name] or $ gitpush origin :[name] 

 

*Create an empty branch: (Remember to submit the changes to your current branch before executing the command, otherwise you will be forced to delete it without regret)

$git symbolic-ref HEAD refs/heads/[name]

$rm .git/index

$git clean -fdx

 

3) Version (tag) operation related commands

View version: $ git tag

Create version: $ git tag [name]

Delete version: $ git tag -d [name]

View remote version: $ git tag -r

Create remote version (local version push to remote): $ git push origin [name]

Remove remote version: $ git push origin :refs/tags/[name]

Merge the tags of the remote warehouse to the local: $ git pull origin --tags

Upload local tags to remote warehouses: $ git push origin --tags

Create annotated tags: $ git tag -a [name] -m 'yourMessage'

 

4) Submodule related operation commands

Add submodule: $ git submodule add [url] [path]

   $git submodule add git://github.com/soberh/ui-libs.git src/main/webapp/ui-libs

Initialize submodules: $ git submodule init ---- run only once when the repository is first checked out

Update submodules: $ git submodule update ---- need to run after every update or branch switch

Delete submodule: (Go in 4 steps)

 1) $ git rm --cached [path]

 2) Edit the ".gitmodules" file and delete the relevant configuration nodes of the submodule

 3) Edit the ".git/config" file and delete the relevant configuration nodes of the submodule

 4) Manually delete the remaining directories of submodules

 

5) Ignore some files and folders without submitting

Create a file named ".gitignore" in the root directory of the warehouse, and write the folder name or file that is not needed. Each element can be on one line, such as

target

bin

*.db

 

=====================

Git common commands

git branch View all local branches
git status View current status 
git commit Submit  git  branch
-a View all branches
git branch -r View all local branches :ndshow git push origin master Push the file to the server  git remote show origin Display the resources in the origin of the remote library  git push origin master:develop git push origin master:hb-dev Associate the local library with the library on the server  git checkout --track origin/dev switch to remote dev branch git branch -D master develop delete local library develop git checkout -b dev create a new local branch dev git merge origin/dev merge branch dev with current branch git checkout dev switch Go to the local dev branch git remote show to view the remote library git add . git rm file name (including path) Delete the specified file from git














git clone git://github.com/schacon/grit.git pull the code down from the server
git config --list see all users
git ls-files see committed
git rm [file name] delete a file
git commit -a Commit all changes in the current repos
git add [file name] Add a file to git index
git commit -v When you use the -v parameter, you can see the difference in
commit git commit -m "This is the message describing the commit" Add commit information
git commit -a -a stands for add, add all changes to the git index and then commit
git commit -a -v General commit command
git log Look at the log of your commit
git diff Look at the ones that have not been temporarily stored Update
git rm aa remove file (delete from staging area and workspace)
git rm --cached aa remove file (delete from staging area only)
git commit -m "remove" remove file (from Git delete)
git rm -f aa forcibly remove the modified file (delete from the staging area and work area)
git diff --cached or $ git diff --staged to view the updates that have not been submitted
git stash push push the file to a in temporary space
git stash pop pops files from temporary space
---------------------------------------- -----------------
git remote add origin [email protected]:username/Hello-World.git
git push origin master Submit the local project to the server
---- -------------------------------------------------- -----
git pull local and server-side synchronization
-------------------------------------- ---------------------------
git push (remote repository name) (branch name) Push the local branch to the server.
git push origin serverfix:awesomebranch
-------------------------------------------- ----------------------
git fetch is equivalent to getting the latest version from the remote to the local, it will not automatically merge
git commit -a -m "log_message" (-a is to submit all changes, -m is to add log information) Local changes are synchronized to the server:
git branch branch_0.1 master Create branch_0.1 branch from master branch master
git branch -m branch_0.1 branch_1.0 rename branch_0.1 to branch_1.0
git checkout branch_1.0/master switch to branch_1.0/master branch
du -hs

------------ ---------------------------------------------------------
mkdir WebApp
cd WebApp
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin [email protected]:daixu/WebApp.git

git push -u origin master

https://blog.csdn.net/dengsilinming/article/details/8000622

$ git push-uorigin master

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324589685&siteId=291194637