Git & GitHub related

Source: Internet
Author: User
Tags git commands

 

 

Permission error (error: the requested URL returned error: 403 forbidden while accessing ):
1. Put the SSH public key of your machine in setting-> SSH keys of GitHub;
2. modify $ bash /. https: // * in the URL in git/config is url = SSH: // [email protected]/zwchan/memcached. git, of course, points to its own GitHub project.

-----------------------------------------------

Common git commands (including deleting files) GitCommon Operation Command collection: 1) remote warehouse commandsWarehouse detected: $ GitClone Git: // Github.com/jquery/jquery. GitView remote Repository: $ GitRemote-V Add a remote Repository: $ GitRemote add [name] [url] Delete remote Repository: $ GitRemote RM [name] Modify remote Repository: $ GitRemote set-URL -- Push[Name] [newurl] Pull remote Repository: $ GitPull [remotename] [localbranchname] Push remote Repository: $ Git push[Remotename] [localbranchname] 2) branch operation commandsView local branches: $ GitBranch: $ GitBranch-R: $ GitBranch [name] ---- note that after the new branch is created, it will not automatically switch to the current branch: $ GitCheckout [name]: Create a new branch and switch to the new branch immediately: $ GitCheckout-B [name] Delete branch: $ GitThe branch-d [name] -----D option can only delete the branches that have already been merged. To forcibly delete a branch, use the-D option to merge the branch: $ GitMerge [name] ---- merge the branch named [name] with the current branch to create a remote Branch (local branch PushTo remote): $ Git pushOrigin [name] Delete remote branch: $ Git pushOrigin: heads/[name]

I created an issue5560 branch from the master branch. After some modifications, I usedGit pushThe origin master submits the request, but the result is 'Everything up-to-date '.Git pushThe origin master node submits the master branch by default in the local branch without the Track Remote branch, because the master branch points to the origin master branch by default.Git pushOrigin issue5560: the master can push the issue5560 to the remote master branch.

If you want to submit a local branch named test to a remote warehouse and use it as the master branch of the remote warehouse or as another branch named test, you can do this.

$ Git pushOrigin test: Master // submit the local test branch as the remote master branch // it seems that you only write this sentence, and remote GitHub will automatically create a test Branch
$ Git pushOrigin test: Test // submit the local test branch as the remote test Branch

What if I want to delete a remote branch? Similarly, if the left branch is empty, the remote branch on the right is deleted.

$ Git pushOrigin: Test // The Remote Test submitted will be deleted, but it will be saved locally. 3) version (TAG) related commandsView version: $ GitTag creation version: $ GitTag [name] Delete version: $ GitTag-d [name] to view the remote version: $ GitTag-r creates a remote version (local version PushTo remote): $ Git pushOrigin [name] delete a remote version: $ Git pushOrigin: refs/tags/[name] 4) submodule related operation commandsAdd sub-module: $ GitSubmodule add [url] [path] such as: $ GitSubmodule add Git: // Github.com/soberh/ui-libs. GitSrc/main/webapp/UI-libs initialization sub-module: $ GitSubmodule init ---- update the sub-module only once when the first warehouse is checked out: $ GitSubmodule Update-after each update or switch branch, you need to run the following command to delete the sub-module: (step 4) 1) $ GitRm -- cached [path] 2) edit the ". gitmodules" file and delete the configuration nodes of the sub-module. 3) edit ". Git/Config file, delete the configuration nodes of the sub-module 4) manually delete the remaining directories of the sub-module 5) Ignore some files and folders and do not submit them.Create the name ". the file gitignore is written into an undesired folder name or file. Each element occupies one row, such as targetbin *. DB git operation-Date of File Deletion: 2012-05-20 Source: bg090721 share:

 

Delete files in git

Rm add2.txt

Git RM add2.txt

Git commit-M "RM test"

Git push Web

 

----------- At Server

CD/var/www/Foo. Git; sudo git Update-server-Info

 

------------ Check the deletion Effect

CD; RM foo3-RF; git clone http: // [an IP address]/Foo. Git foo3

 

------------ Update an existing local code

CD; CD foo2

Git remote add web [a user] @ [an IP address]:/var/www/Foo. Git/

Git pull Web master

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.