Setup Git
GitLab

Setting Up Git


Return to your VSCode application window. It is now time to setup and initialize your GitLab repo.

Step 1 - Change Directory Back to Project Top Level

Ensure you are at the top level directory for your project folder:


cd ~/workspace/ndfclab/nac


Step 2 - Set Git User Global Settings

Set your Git global settings:


git config --global user.name "Pod06"
git config --global user.email "pod06@cisco.com"
git config --global init.defaultBranch main


Step 3 - Initialize Local Directory as Git Repo

Initialize your local project directory as git repo:


git init


    Initialized empty Git repository in /home/pod06/workspace/ndfclab/nac/.git/

Step 4 - Add Remote Pointer to Git Repo

Add pointer to your GitLab remote repository.


git remote add origin git@10.15.0.159:Pod06_2025_01/LTRDCN-3439.git


Step 5 - Create .gitignore File

In Git repos, it is very common to have a hidden file called .gitignore. This is a reserved filename and it is used to ignore specific file extensions and/or directories from being added to the Git repo. An example of a specific file you do not want added to your Git repo is your .python-version hidden file that specifies your pyenv environment.

  
touch ~/workspace/ndfclab/nac/.gitignore
cat << EOF > ~/workspace/ndfclab/nac/.gitignore

/collections
*.env
scripts/
ansible.cfg
secrets.sh

# VScode 
.vscode/*

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# pyenv
.python-version
EOF


Step 6 - Add Files for Committing to GitLab Repo

Add your current files to your staging area for committing to your GitLab repo.


git add .


Step 7 - Double Check Files Staged For Commit

Check your git status of your working directory and staging area.


git status .


The following files are staged for commit. Make sure your list matches the output below!

    On branch main

    No commits yet

    Changes to be committed:
    (use "git rm --cached <file>..." to unstage)
            new file:   .gitignore
            new file:   group_vars/ndfc/connection.yml
            new file:   group_vars/ndfc/ndfc.yml
            new file:   host_vars/fabric-external-stage/fabric.nac.yml
            new file:   host_vars/fabric-external-stage/global.nac.yml
            new file:   host_vars/fabric-external-stage/policy.nac.yml
            new file:   host_vars/fabric-external-stage/topology.nac.yml
            new file:   host_vars/fabric-stage/fabric.nac.yml
            new file:   host_vars/fabric-stage/global.nac.yml
            new file:   host_vars/fabric-stage/interfaces_access.nac.yml
            new file:   host_vars/fabric-stage/interfaces_routed.nac.yml
            new file:   host_vars/fabric-stage/interfaces_vpc.nac.yml
            new file:   host_vars/fabric-stage/networks.nac.yml
            new file:   host_vars/fabric-stage/poap.nac.yml
            new file:   host_vars/fabric-stage/policy.nac.yml
            new file:   host_vars/fabric-stage/topology.nac.yml
            new file:   host_vars/fabric-stage/underlay.nac.yml
            new file:   host_vars/fabric-stage/vpc.nac.yml
            new file:   host_vars/fabric-stage/vrf_lite.nac.yml
            new file:   host_vars/fabric-stage/vrfs.nac.yml
            new file:   hosts.stage.yml
            new file:   requirements.txt
            new file:   requirements.yml
            new file:   vxlan.yml

Step 8 - Commit Files to the GitLab Repo

Issue a git commit which is like a save point of your current local repo.


git commit -m "Initial Commit"


    [main (root-commit) bb2a31a] Initial Commit
    24 files changed, 453 insertions(+)
    create mode 100644 .gitignore
    create mode 100644 group_vars/ndfc/connection.yml
    create mode 100644 group_vars/ndfc/ndfc.yml
    create mode 100644 host_vars/fabric-external-stage/fabric.nac.yml
    create mode 100644 host_vars/fabric-external-stage/global.nac.yml
    create mode 100644 host_vars/fabric-external-stage/policy.nac.yml
    create mode 100644 host_vars/fabric-external-stage/topology.nac.yml
    create mode 100644 host_vars/fabric-stage/fabric.nac.yml
    create mode 100644 host_vars/fabric-stage/global.nac.yml
    create mode 100644 host_vars/fabric-stage/interfaces_access.nac.yml
    create mode 100644 host_vars/fabric-stage/interfaces_routed.nac.yml
    create mode 100644 host_vars/fabric-stage/interfaces_vpc.nac.yml
    create mode 100644 host_vars/fabric-stage/networks.nac.yml
    create mode 100644 host_vars/fabric-stage/poap.nac.yml
    create mode 100644 host_vars/fabric-stage/policy.nac.yml
    create mode 100644 host_vars/fabric-stage/topology.nac.yml
    create mode 100644 host_vars/fabric-stage/underlay.nac.yml
    create mode 100644 host_vars/fabric-stage/vpc.nac.yml
    create mode 100644 host_vars/fabric-stage/vrf_lite.nac.yml
    create mode 100644 host_vars/fabric-stage/vrfs.nac.yml
    create mode 100644 hosts.stage.yml
    create mode 100644 requirements.txt
    create mode 100644 requirements.yml
    create mode 100644 vxlan.yml

Step 9 - Push Files to the GitLab Repo

With your local repo added and committed to staging, push your content to your remote GitLab repo.


git push -u origin main


    Enumerating objects: 31, done.
    Counting objects: 100% (31/31), done.
    Delta compression using up to 8 threads
    Compressing objects: 100% (29/29), done.
    Writing objects: 100% (31/31), 5.64 KiB | 825.00 KiB/s, done.
    Total 31 (delta 4), reused 0 (delta 0), pack-reused 0
    To 10.15.0.159:Pod01_2025_01/LTRDCN-3439.git
    * [new branch]      main -> main
    Branch 'main' set up to track remote branch 'main' from 'origin'.

Step 10 - Return to GitLab and Verify Repo Is Populated

In Gitlab, you need to refresh the page to see your repo populated.

  1. Click the project name, LTRDCN-3439




  2. Once you've clicked the project name, LTRDCN-3439, your repo should be populated with the files you just committed.




Continue to the next section to create your production fabric configuration data model files and get them commited to your repo.