We can easily create a project in GitLab and "synchronize" it with git :
$ git clone [email protected]:user/teste.git
But what about backwards?
Create the folder and the local project, and send as a "new" in GitLab ?
We can easily create a project in GitLab and "synchronize" it with git :
$ git clone [email protected]:user/teste.git
But what about backwards?
Create the folder and the local project, and send as a "new" in GitLab ?
I think you're talking about sending set a remote repository to an existing project.
I usually do this:
git init
git add .
to select all files (optional, if you want to do one by one you can, just an example) git commit -m "primeiro commit"
git remote add origin [email protected]:user/teste.git
git push -u origin master
On the fly, you are sending location data from an existing repository on your machine.
Summary of what I did above through BASH:
>>> mkdir projeto
>>> cd projeto
>>> git init
>>> git add .
>>> git commit -m "primeiro commit"
>>> git remote add origin [email protected]:user/teste.git
>>> git push -u origin master
If you are trying to use an existing repository that has another source, you will not be able to use the git remote add origin
command. In this case, use git remote set-url origin [email protected]:user/teste.git
, but only if you already have a repository with origin , and do not create one from scratch.
Then just do git push -u origin master
.
git-init
Starts a git
pository. When you run this command, you are saying that, from now on, that directory will have GIT version control.
git-add
Adds the contents of one or more files to the change index. When you do git add readme.txt
, you are saying that changes made to readme.txt
will be saved in the next commit.
I like to use git add
and add the changes I made to a topic.
For example:
I created a button on the user registration page that verifies that the email is valid. For this, I created the button in criar-usuario.html
and in criar-usuario.js
I made the ajax call that will make this query.
You can do this to process the changes:
>>> git add views/criar-usuario.html js/criar-usuario.js
Then when you do commit
, only the two files will be added to the list of modifications.
When you use the dot ( git add .
), you are saying that all files will be added.
git commit -m
Process the changes reported in git add
and adds to the change history. In the case above, the -m
flag indicates that you are reporting the commit message directly in the command call. If you only use git commit
, a window that usually uses vim
or nano
(common code editor on Linux) will open for you to put the commit
message.
Commit messages need to describe what you did.
Using the previous example:
>>> git add js/cadastro-usuario.js views/cadastro-usuario.html
>>> git commit -m "Adicionando botão de consulta de e-mail"
git remote add origin url_do_repostiório
You are saying that the place where GIT changes will be saved remotely will be the url informed.
This command is generally used when you create a repository with git init
, because it just adds version control. The git remote add origin
tells the server where you will save the changes.
git push -u origin master
git push
sends the commit information you created to the server.
The commits are being added to the queue and you can see which ones were not sent through the command git status
.
-u
is usually used in the first commit and origin master
indicates that branch
of source will be master
. master
is usually the default% of GIT%.
I will not dwell too much on Branchs. Read about it here: