README.md and file-1.įor the demo, I have added another file “file-2.txt” as shown below. Just to remind, this folder contains two files i.e. Now, let me add a file in the local repo while working in hello-git-branch branch and see if it affects the master branch or not?įor that, I am adding a new file to the local system folder that we created for our examples. hello-git-branch.Īs we checkout and in the hello-git-branch branch. First, the master branch and the other that we just created i.e. We have two branches in our local repository now. Now you may work on the locally created branch independently. You can see, both branches contain the same content. This command should switch us from the master branch to newly created “hello-git-branch” branch.įor seeing what it contains, run this command:įor showing the difference, the graphic below lists the content of master branch as well as the newly created branch. If you want to see the content of this branch then run this command: This should create a new branch namely “hello-git-branch”. Go to the Git Bash and write this command for creating a new branch based on the master branch: You can see, the local repo now contains both files that we have in the remote repository (on Github website).įinally, we reached the topic for what you are here “how to create a new branch”. See the graphics below what this command resulted: This command should pull all files from the “master” branch in the remote repo into your local repo. Use this command to pull files from the remote repository: You have to change the URL as per your repo.Īfter executing this command in Git Bash, this should show no message. You have to specify the path that you may get from Github website as shown below: Now run this command for synchronizing your remote repository with local. Now, if you look at the folder, it should show. First, we will synchronize the Github repository with the local repository.įirst of all, run the following command on Git Bash: Until now, our local folder contains nothing. Step 3: pull Github repo into the local machine This should open the command line prompt for the Git Bash where you may write commands to work with this version control system. Open that folder and right click on it and press “Git Bash Here” option as shown below. For the demo, I used E drive and created a folder “git-local”. Now go to the directory where you want to create a local repository. If you have not done so, you may install it by visiting this website and download/install it on your machine. I have installed Git software on windows machines with Git Bash. However, for learning how to create branches by command-line, we will create a new branch based on master branch. Note: If you look at the above graphics (after creating a repo), it shows the master branch is already created. Our repository now contains two files as shown below: If you check the “Initialize this repository with README” option then the new repo should contain a file “README.md”.įor branch testing, let us create a file in this repository so that we can see later what a branch contains.įor the demo, I have created ‘file-1’ and just a line of text.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |