Trading View Automation
  • Introduction
  • Setting Up Local Server
    • Setting Up HashiCorp Vault + EthSigner
    • Setting Up HashiCorp Vault (dev) + EthSigner
  • Setting Up Google Cloud Run
    • Setting Up Google KMS
  • Setting Up Heroku
  • Setting Up Env Vars
  • Setting Up Trading View Alert
  • Testing With sendAlert.js
  • Setting Up Google Sheets
  • Setting Up Telegram Notifications
  • Using Tmux
  • Using Git
Powered by GitBook
On this page

Using Git

When using Git, you are syncing changes between your local repository and a remote repository (e.g., a Github repository). The Github remote repository is usually labeled "origin".

Useful commands

git clone <https or ssh url> clones a remote Github repo

First example below uses "https" method; second one uses "ssh" method.

git clone https://github.com/brianonchain/trading-view-automation.git

git clone git@github.com:brianonchain/trading-view-automation.git

git branch -vv lists all local branches, the remote branch each local branch is "tracking", and the last commit message

For example, the "dev" local branch tracks the "origin/dev" remote branch. An asterisk appears next to the "checkedout" branch, so this command is useful if you forget which branch you are on.

After you clone a repository and run git branch -vv, you will see only one local branch called "main", which is tracking "origin/main". If you run git switch dev and if the "dev" branch does not yet exist, it will be automatically created and also "track" the remote branch with the same name.

git switch <branch> switches to a different branch locally

The branch that you switch to is called the "checkedout" or active branch. The trading-view-automation Github repository has two branches: "main" and "dev".

git pull and git pull origin <branch> pulls changes from the Github repo and merges it to the local "checkedout" branch

Therefore, always be aware of what is the "checkedout" branch before using git pull.

If you run git clone <url> and then run git switch dev, you should have the correct setup (i.e., your local "main" and "dev" branches are tracking the remote "main" and "dev" branches, respectively). To pull changes, simply switch to the desired branch and run git pull .

If your local branch is not tracking a remote branch or you want to pull changes from a remote branch other than the tracked branch, run git pull origin <branch>. This will pull changes from the remote branch with name<branch> and merge them into your local "checkedout" branch.

To push changes to the Github repo, use 3 successive commands: git add ., git commit -m <message>, and git push (or git push -u origin <branch>)

git add . adds all files that have been changed to a "staging" area git commit -m "message" takes a snapshot of the current local repository and stores it locally git push (or variations) pushes this snapshot to the remote repository

If your local "main" and "dev" branches are tracking the remote's "main" and "dev" branches, then using git push is sufficient. If your local branch is not tracking any branches or if you want to push your changes to a remote branch other than the tracked branch, use git push origin <branch>. Adding a -u flag will enable "tracking" between your local branch and the remote branch you just pushed to, which is desirable most of the time. Once tracking is established, git push is sufficient.

PreviousUsing Tmux

Last updated 6 months ago