How to connect local folder to Git repository and start making changes on branches?

Viewed 127453

I'm new to source control; in the past, I've manually backed up copies of files and made changes on clones then transferred changes manually to master files once debugged. I realize this is similar to how branches work with Git repositories, however I've never used one.

I downloaded Git and made an account on GitLab, and started a new project. My site is hosted on a local server and my files are saved locally. How do I connect these files to a Git repository and continue developing with branches?

2 Answers

Idk if necessary, but I've always named my local folder the same as the remote repo.

Also, prior to a git push, I try to:

git pull origin master

in order to get the latest code in the repository. Then I can port in my changes and commit.

Total text from GitHub:

echo "# xyz_repo" >> README.md

git init

git add README.md

git commit -m "first commit"

git branch -M main

git remote add origin https://github.com/mikeyj777/Coursera_DataStructsAndAlgos.git

git push -u origin main
Related