Git – Configure User and Add new Files to Repository

Before going to configure user, first, we will check the repository history by executing below Git command in Git CMD (Deprecated)

 

git log

 

The output displays all commit details as shown below.

 

C:\Examples\techExamples>git log

commit 78d20f994642f6f19bae8be0a7378cc24bd598b6 (HEAD -> master)

Author: Raj <xxx.xxx@hotmail.com>

Date:   Sat May 11 19:39:30 2019 +0100

    'InitialChanges'

C:\Examples\techExamples>

 

As shown above, it displays the username, email, and commit details. We can configure user by using git config command. Go to the local repository and execute below commands.

 

git config –global user.name Raj (to configure username)

git config –global user.email xxx.xxx@hotmail.com (to configure user email)

 

Now we will add new files to our local repository and push to VSO. Create new html in local repository folder C:\Examples\techExamples. I have created a contact.html file. Add this page to the local repository by using git add command as shown below.

 

git add contact.html

 

You can add multiple pages also by using git add command.

 

git add contact.html about.html

 

Let’s check the status of the repository by using the git status command.

 

C:\Examples\techExamples>git status

On branch master

Your branch is based on 'origin/master', but the upstream is gone.

  (use "git branch --unset-upstream" to fixup)

 

Changes to be committed:

  (use "git reset HEAD <file>..." to unstage)

 

        new file:   about.html

        new file:   contact.html

C:\Examples\techExamples>

 

As shown above, git status command displays there are two new files contact.html & about.html but didn’t commit these files. Commit these files by using git commit command with details.

 

C:\Examples\techExamples>git commit -m 'AddedTwoFiles'

[master 73af988] 'AddedTwoFiles'

 2 files changed, 16 insertions(+)

 create mode 100644 about.html

 create mode 100644 contact.html

 

C:\Examples\techExamples>

 

Now push the changes to the server through git push command.

 

C:\Examples\techExamples>git push https://dev.azure.com/vsotech/_git/techExamples

Enumerating objects: 5, done.

Counting objects: 100% (5/5), done.

Delta compression using up to 4 threads

Compressing objects: 100% (4/4), done.

Writing objects: 100% (4/4), 499 bytes | 166.00 KiB/s, done.

Total 4 (delta 0), reused 0 (delta 0)

remote: Analyzing objects... (4/4) (58 ms)

remote: Storing packfile... done (94 ms)

remote: Storing index... done (41 ms)

To https://dev.azure.com/vsotech/_git/techExamples

   78d20f9..73af988  master -> master

 

C:\Examples\techExamples>

 

You can find all these files in the server repository, VSO. Go to your VSO by login to https://dev.azure.com, select your project and go to the repository by selecting "repos" opens. In my case, my server repository locates at https://dev.azure.com/vsotech/_git/techExamples.

 

You can check commit history also by selecting the “History” option.