Configure git to existing project folder

Asked

Viewed 10,963 times

2

I have a project already underway where we are adopting Scrum as a development methodology.

Git is all set up to commit and clone, it’s working perfectly.

My question is, do you have a way to clone git to an existing folder with project files or do you have to create a new folder? For when I point to an existing folder it does not allow.

3 answers

5


Unable to clone a Git repository to a folder that is not empty, this is not allowed.

If any development has been done outside the repository, do the following:

  1. Clone the repository
  2. Create a new Rach
  3. Throw the code over this branch, if it’s in the same structure, otherwise you’ll need to copy over it individually
  4. Resolve the conflicts
  5. Do the commit
  6. Do merge branch
  • Why not add the remote and merge?

  • Maybe so, but I don’t think there’s a local repository

  • 1

    I find it less traumatic to start the repository in the current directory, then there would be a location

3

Alternatively, you can start a repository or repository locally with git init.

After doing this, I recommend that you do the commits locally, even to avoid losing work case give some problem or you unintentionally execute some command with occasional side effect on the data.

Okay, after you commit, we’ll add the remote Github repository. You can follow the own tutorial from Github, or memorize some commands (explanation below command:

git remote add origin [email protected]:user/projeto-muito-legal-show.git
#              \___/   \____________________________________________/
#                |            endereço remoto do projeto no github
#         apelido do repositório remoto

git fetch origin

Ready, now you have a properly configured remote. After that, we can mix your branch place with the branch remote (if something has already been created). Or if the repository is still empty, just push.

To mix, it is usually used git merge origin/master (documentation) to mix with the branch master from the Github repository. But you can also try rewriting the history by all commits that you made as being children’s commits from the tip of branch remote, using the rebase (documentation).

git merge origin/master    # para fazer o merge
git rebase origin/master   # para fazer o rebase

In the third case, you still have nothing on the remote. So you just need to give a git push -u origin master (see more in this question, see the documentation).

  • So for example, with this setup, when I upgrade, or some member of the team upgrade, will I be able to see that there’s something new to update? that’s what’s catching

  • What you’re talking about is tracking a remote branch. If you solve using the git push -u, i the branch created on the remote becomes already tracked. If you go through the merge or of rebase, need to set in hand. A moment

  • Apparently it’s with git branch -u origin/master: https://stackoverflow.com/a/2286030/4438007

  • Trying to explain more clearly. I have a server already with github configured. What I want to know is, when I put this commit on the server, someone who’s pointed to this github, get automatic update and kind of do the "clone" directly

  • @Gabrielfalieri how do you have a server with Github? It is not the web service that is available at http://github.com no?

  • Github server that I speak of, the person here set up the server github... think n by the web service

  • I think you just created the repository from github desktop

  • This process of pulling the updates is the git pull, is already something very standard of git. How experienced is the team dealing with git?

  • Actually I changed company a little while ago, not working right with git

  • Okay, so I think it’s a good start from scratch. Clear your head, learn right. I like the tutorial by Atlassian. There are also in Udacity a course dedicated to git

  • I ended up using Tsc

Show 6 more comments

-2

if you already have a repository created and a local project and want to upload the changes to your repository and only use the git remote add orig command

git remote add origin "repository location" git push -u origin master

ex: git remote add origin https://[email protected]/user/project.git git push -u origin master

  • This question already has a certain age, and it already has answers. It is expected that, in these cases, new answers bring information new, approaches distinct, but I saw nothing new in his reply.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.