Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Git command and Github

Shulou Source: shulou.com Published: 2022-06-03 04:41:29 09月12日 Update

Basic operation

Create a new warehouse Test on Github, do not initialize it, then install Git locally, create a directory with the same library name, Test, and enter the directory. Right-click Git Bash HERE and follow the following command:

Echo "# Test" > > README.md

Git init

Git add README.md

Git commit-m "first commit"

Git remote add origin https://github.com/erryeng/Python-practices.git

Git push-u origin master

* pull the project locally from the Github website

Local installation SSH address of the copy project on the gitGithub website create a new folder locally to enter this folder, and then Git Bash Here run the command: ssh address of git clone copy * *

The command explains:

Git init

Initialization, which will create a subdirectory called .git (the files in the project have not been tracked yet)

Git add README.md (git add * .py)

Track files

Git add.

Commit all changes to the staging area, including file content modification (modified) and new files (new), but excluding deleted files

Git add-A

All, including add and non-add

Git commit-m "first submission"

After tracking the file, submit it

Git remote add origin https://github.com/jerryfeng007/Python-practices.git

Add a remote repository (later, you can use origin instead of the entire url)

Git push-u origin master

Push the local master branch to the origin host, and specify origin as the default host, then you can use git push without any parameters.

Create a development branch development project

Create a new branch on github develop view remote branch, git branch-r local new branch, git branch develop view local branch, git branch view all branches, git branch-a view current branch, git branch-a, switch to develop branch with *, git checkout develop view current branch, with *, git branch-a development completed, git add (such as git add * .py) git commit-m "submission time" Submit content, etc. "submit to the develop branch, git push origin develop to check whether the github has been modified by push. At this time, if the master is modified by someone else, then you are not up to date locally. Switch to the local master branch, git checkout master pulls the latest code, git pull origin master merges the code on the develop branch into the master,git merge develop view status, and git status submits to the remote master,git push."

Other

Delete the local branch, git branch-d test2 delete the remote branch, git push origin-- delete test2

After the branch is deleted from Github, it is viewed locally using git branch-a, and still exists

Execute orders, git remote prune origin

Use git branch-a to view again and delete it.

Tags: Branches files commands projects development tracking hosts repositories code content addresses copies folders directories websites switching same again parameters at the same time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia vpn Shulou Technology macOS MariaDB