Creating a Local Repository
Goal: By the end of this document, you will have created a git repository, created a new file, staged the file and committed it to your local repo.
Last updated
Goal: By the end of this document, you will have created a git repository, created a new file, staged the file and committed it to your local repo.
Last updated
Once you have installed SourceTree (or other client) you are ready to experiment with git. The first step is to create a git repo. We are going to use SourceTree to perform all of these actions for now.
Open SourceTree and click the + symbol in top menu bar or choose FILE -> Clone/New
in the tool bar.
Click on CREATE in the tool bar that appears
If you followed the pattern outlines in the section, navigate to Sites\UML\WebDataImplementation\
and make a new folder called "practiceGit"
If you didn't, simply choose a empty folder.
Click Create.
Use either Windows Explorer or Finder to go to the practiceGit
folder. Make sure you have it configured to see hidden files and folders ( Google how if you need to). You should see a folder called ".git" folder. This is where git will save all the information it needs to manage all the branches for the repository ( or repo ) in this folder. Note: DO NOT SAVE ANY FILES IN THAT FOLDER. Also, do not edit any of the files in that folder. Bad things to your work can happen. Let git handle it all.
Open a text editor (like Notepad or TextEdit. Do Not use Microsoft Word or Pages. In TextEdit, make sure you choose FORMAT -> make Text File
if necessary) and create a new file called "MyFirstText.txt" in your git1 folder.
Type "This is my first file with git. So far so good." and then save into that practiceGit
folder. This saves the file onto your hard drive but it is NOT in your git repository yet.
Go back to SourceTree and click on the "practiceGit
" tab. If you closed that tab, click on the + sign again and use ADD to open that repo again.
In the left hand menu pane, under WORKSPACE, click on FILE STATUS.
In the lower half of the center column you should see a section called "UNSTAGED FILES" and in it your MyFirstText.txt file should be listed. Click on it.
You should see the contents of your file appear in the upper right.
Back in the center column, click on "STAGE SELECTED" (On Mac: right click and choose Stage Files
). This will move MyFirstText.txt from the unstaged area to the STAGED FILES area. This area is a list of all the files which are going to be put into your repo but are not there yet.
At the bottom of the screen you will see a text box with the button COMMIT underneath it. In the text area, type "INITIAL COMMIT". It is customary to put a comment describing the work you did for each commit.
Click Commit. This will put your file into the git repository in that folder. It is now in the version control system and managed by git.
Look in the left menu panel under BRANCHES and notice that one called "master" has been created. It is in bold which means that is the branch which is currently checked out so all the files, no matter what program in which you open then, will be editing the files in this branch.