Git#

Exectations#

Pull at the beginning of the day, push at the end of the day on any branches you are working at a minimum.

Conventions#

The main branch is used as a main stable branch. dev branch is to be used for development. feature branches are used to develop individual pieces.

Feature branches should be named according to the current scope of work as found within the agenda section of the repository. i.e. “scope3”.

Clone Repository#

  1. Make a local directory if it does not exist for repositories within your user directory according to best practice location:

    mkdir -p ~/Repositories

  2. Navigate to the local directory for repositories within your user directory:

    cd ~/Repositories

  3. Clone the metacrud2 repository from the server to your local repositories directory on the dev branch:

    git clone --branch dev git@git.systems.exact.engineering:/git/metacrud2

Listing remote feature branches#

git ls-remote

Listing local feature branches#

git branch -a

Creating a new feature branch#

If the current scope of work does not have a branch yet either locally or remotely, create it using the following steps:

  1. Fetch the most recent version of the dev branch(does not automatically merge like a pull command would):

    git fetch origin dev

  2. Create a new feature branch based on the dev branch regardless of what branch you are currently on(Use this convention but change the scope number to whichever one is currently applicable):

    git checkout -b scope3 dev

  3. Push the newly created remote branch to the origin server:

    git push origin scope3

Check current branch and status#

Before committing, it is a good idea to confirm the current branch and pending changes to be made in upcooming steps:

git status

Committing to braches#

  1. Commit by adding a single file(git add newFile) or all uncommitted changes(git add .)

  2. Commit changes that have been added to local branch:

    git commit -m "Added new file"

Pushing a feature branch#

  1. Ensure the most recent remote branch is incorporated into the local branch to minimize potential conflicts:

    git pull origin scope3

  2. Push changes within local branch to remote server:

    git push origin scope3

Merging a feature branch#

  1. Check current branch status to confirm all changes are committed:

    git status

  2. Fetch the most recent changes from the dev branch to your local machine:

    git fetch origin dev

  3. Switch to the dev branch on your local machine:

    git checkout dev

  4. Merge your existing featuree scope into the dev branch:

    git merge scope3

Delete a local branch#

  1. Check the status of the branch for uncommitted changes:

    git status

  2. Push the local branch to the server to preservee all changes:

    git push origin scope3

  3. Delete the local branch:

    git branch --delete scope3