Today we will go through setting up git and creating our first repository.
Follow the steps below:
- Download Git on your system from here Download Git based your operating system and install it following the set up instructions.
- After installing you can use the command git --version and check the version you are using.
- Create a folder and after creating it right click on the folder and you will see an option git bash here. Click on it and you will see a git command line opened.
- It will open a command prompt with the folder location created in step 3 as shown below
- Now we will initialize this as a local git repository using the command git init.
- Now we can add files in this folder. Once the changes are made we will first stage these changes by using command
git add <Filename>. - We can use this command number of times and add files or we can use command
git add -A
to add all files in the folder. - After all the files are added we need to commit the changes. This is done by using command
git commit -m "Your message here". - Before committing it will ask to set username and email to identify the users who are committing to this repository. These values can be set by using commands
git config --global user.name "Your Name"
git config --global user.email "Your Email"
If you want to make use of the details for only this repository you can omit global and run the commands. - Once commit is made all the files and changes you made are committed and are tracked now.We need to push this changes to remote repository.
- Now go to Github and login to your account.
- After signing in create a repository.
- After creating repository you will be directed to a page as below. Since we already have a local repository we will use second section commands.
git remote add origin https://github.com/narendravenkata/Test-Demo.git
- Now we have provided the remote local where to push our local repository . Now before pushing the changes we need to set the upstream branch .This is done as follows.
git push -u origin master
When pushing it will prompt for username and password , please enter your github login credentials.
This will push the changes and you can refresh the browser and will see the files and changes you made.
No comments:
Post a Comment