Skip to content

Latest commit

 

History

History
153 lines (140 loc) · 3.27 KB

File metadata and controls

153 lines (140 loc) · 3.27 KB

Clone a Repo

git clone git@$GIT_HOST:operation/nagios.git

Adding a file explained

git pull                -> like: svn up
git add <file>          -> If its a new untracked file
git commit -m'message'  <file>       -> commits the file to your local repo (untracked file)
git push                -> pushes local changes to the source git repo

Update and existing File explained

git pull
git commit -m'message' -a <file>      -> commits the file to your local repo
git push

Basic change workflow

  1. Get the latest changes
git pull
  1. Make your change
vi somefiles
  1. Make sure your changes are good
git diff
  1. Add to the staging area, and commit
git add somefiles
git commit
  1. Grab possible changes that happened while you were editing, ..* --rebase is your friend, it will avoid to create a merge commit
git pull --rebase
  1. Push your changes
git push origin HEAD:refs/for/master

If you happen to have a conflict

  1. Edit the files in conflict
vi somefiles
  1. add them, it means "resolve" to git
git add somefiles
  1. Resume the rebase
git rebase --continue
  1. And just to make sure you're up to date, do it again
git pull --rebase
  1. Push your changes
git push origin HEAD:refs/for/master

Permanently remove a file and all history

git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch [filename]' --prune-empty --tag-name-filter cat -- --all
git push origin --force --all

BRANCH STYLE CHANGES

  1. update local copy in master branch
git pull
  1. Create branch
git checkout -b TICKET
  1. Make changes
  2. Add Files
git add [files]
  1. Commit
git commit -m “ticket etc”
  1. Push
git push -u origin TICKET
  1. Go to UI and submit pull request

Cleanup Branches

Local

git branch -D bugfix

Remote

git push origin --delete <branchName>

or

git push origin :<branchName>

Rebase a branch

BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
git pull --rebase origin production
git push origin ${BRANCH} --force

reset your local repo to match the remote branch

(this has worked when i need it to, but i haven't tried with branches)

git reset --hard origin/HEAD
git reset —hard

tagging

from the master branch you want to tag

git tag -a -m'message' [tag name]
git push origin [tag name]

Using RestAPI to Get list of Team members

First Find the team API endpoint

curl -u user:pass https://[github]/api/v3/orgs/[org]/teams/[team]

Then query that team end point with max per page value to see how many pages there are.

curl -I -u user:pass https://[github]/api/v3/organizations/655/team/250/members?per_page=100

Look for the Link line

Query each page and dump to output fieles

curl -u user:pass --output /tmp/joe "https://[github]/api/v3/organizations/655/team/250/members?page=1&per_page=100"
curl -u user:pass --output /tmp/joe2 "https://[github]/api/v3/organizations/655/team/250/members?page=2&per_page=100"
curl -u user:pass --output /tmp/joe3 "https://[github]/api/v3/organizations/655/team/250/members?page=3&per_page=100"