-
Notifications
You must be signed in to change notification settings - Fork 6
Updating Github from Terminal
If you're developing a bash script or pipeline, uploading it onto github (even if you're not done working on it) is both useful for others and a good way of keeping track of changes and past versions.
As you edit your script in terminal or atom, you will want to commit your changes to github. This page will explain how to access your github repository form terminal and commit your changes.
This will make a local copy of all the current scripts in your repository.
From terminal, execute: git clone https://github.com/your_github_account_name/repository_name
Once the repository is created, it will appear as a folder with the same name in your current bash directory, cd into that folder.
This will be where you can work on your scripts and actively edit them.
Git checkout -b test
This will create a new branch named 'test', and will automatically switch you to this branch. Go ahead and edit your scripts. Any changes that you make to your scripts will remain in this branch, meanwhile your original unedited scripts are still present in the 'Master' branch.
To switch back to the master branch: git checkout master
To double check which branch you are currently in: git status
This will also tell you whether your branches are up to date with the master branch, or whether changes have been made.
This will specify which of the edited files, you actually want to commit.
git add filename
To add all the files in the folder: git add -A
After committing, the tracked files will only be visible on the test branch, and will no longer be visible on the master. They have now become a permanent part of the test branch, and there original version no longer exists (at least not in the local repository).
git commit -m “Description of changes made”
Adding a description of the changes will make it easy for others, and for your future self to figure out where bugs appeared and locate a desired past version of the script.
Now the 'test' branch will appear on your online account.
git push origin name_of_branch
Do this online on your github account after you are convinced that you want your changes to become part of the main script. If you are working with collaborators, they may review the changes before agreeing to merge the branches.
There is no correct answer for this. It would be inefficient to perform a commit every time that you make a minor change. In general, it is useful to perform a commit when you make multiple adjustments that all fall under the same purpose.