- Create a new remote repository (empty)
Create a new remote repository
- Set the name of the remote repository and create
Set the warehouse name
Remember : If we add the Readme and. Ignore files when we create the remote repository, we need to perform the operation after we have associated the warehouse. pull
Create a local folder locally
To create a folder locally
Use terminal to enter the current folder directory
cd /Users/Sunshine/Documents/大神班/练习/0721/helloTest
Use terminal to enter this folder
- Initialize this local folder as a
Git
manageable repositoryinit
Note: Git will automatically create a unique branch for US master
We can find a directory in the current directory .git
, this directory is git to track the management of the repository, do not manually modify the files in this directory, or change the mess, the Git repository to destroy.
Initializing the Local warehouse
Associating a local warehouse with a remote warehouse
Create a new main.m file in the local warehouse
- Push the contents of the local library to the remote
push -u origin master
- Remark:
origin
: remote warehouse name; master
: Branch
- Note: For the first time
push
, with -u
parameters, Git will associate the local master branch with the remote Master branch, and we will push
no longer need to add parameters to our operations -u
.
Push to a remote repository
- We used a browser to access the remote repository and found that there were files in the remote repository
mian.m
A main.m file is also available in the remote repository
- If one day we have modified the mian.m file (here we add a "Hello World" in the main.m file)
Modify the Main.m file
- We can use
git status
view status
View status
Adding files to the Git repository is actually 文件修改
adding to the暂存区
git add main.m
Commit the changes, in effect, 暂存区
all the content is submitted to 当前分支
.
Submit Changes
- View status again
git status
View status again
- Pushes the latest changes to the local current branch to the remote repository on GitHub
push origin master
Push the modified MAIN.M file to the remote repository
- Using the browser to view the remote repository, we see that the local changes have been pushed to the remote repository.
viewing in the remote repository
Summarize
Initialize a local git repository (initialize the local folder to a repository that git can manage)
init
Note: The command line terminal needs to be 当前文件目录
Add files to the local repository
git add 文件名
Submit file changes to the warehouse
commit -m "注释"
Associate a remote Warehouse
git remote add origin git@github.com:YotrolZ/helloTest.git
Push the latest changes to the remote repository
push -u origin master
- Attention:
1. Each push must be preceded git add 文件名
andgit commit -m "注释"
2. When the first push is made, we add the -u
parameters, and we don't need to add parameters when we push. -u
Creation and association of local git repositories and remote repositories