Saturday, 18 March 2017

GIT: How to add a file to local repostiory

1. If you have created a new file in the project, the file will not be added to Git repository until you explicitly tell the Git.
2. When ever you create a new file, or made changes to a file, Git keeps track of changes to the file.
3. "git status" command lets you know, what are the changes added to the project.
4. The result of "git status" command looks like below. I added a file HelloWorld.txt to my HelloWorld project. 

5. By using "git add" command you can add the file to Git repository. The output of "git add" as follows.

6. After executing "git add", execute "git status", you can see the message, branch is uptodate & changes to be committed, with the list of files to commit.
7. You can commit the changes to repository, by executing "git commit" command.

8. executing "git commit" won't push files to online git repository, it keeps files in your local repository.
9. If you want to push files to your repository on, you have to use "git push" command. If you have not configured username & password, it will ask you to enter, just like below.

10. After push, the output looks like below.

11. Now if you go to your online github repository, you can see new file is added. Here you can see new file "HelloWorld.txt" is added to online repository.


Post a Comment

Note: only a member of this blog may post a comment.