Git
Git
Git is great for collaborating on large systems to ensure shared data consistency. After installing git and making changes to a document/s the following are the commonly used commands.
git pull
this will download any changes made since the last push (even from other users so no conflicts occur) sometimes this errors for merge conflicts and will require you to specify the repo and branch:
git pull origin production
This command by itself will tell you if you are in the main branch or if within another.
git branch
To switch branches use:
git checkout BRANCH NAME
you can also create new branches with:
git checkout -b NAME
You need to tell git a new branch is created on your first push with:
git push -u origin NAME
To delete a branch
git push origin --delete <branch>
In general you will run a git pull and then work on either a branch or work on production, make your file edits, add, commit and push. In that order.
Add the files you modified
git add FILE 1
git add FILE 2
Commit the changes to the branch with a reason why:
git commit -m "reason for making these changes"
or add all the files you modified and commit at the same time:
git commit -am "reason for making changes"
Finally push to complete the addition of changes
git push
When troubleshooting you can find information via git grep and git status :
git grep "SEARCH-TERMS"
git status
You may need to look over the log for the last few commits
git log ntp --
commit 3d176c62570382e9b9d81541e7b7c5b7638276d7 Merge: c0bebff df57f27 Author: USER <email@domain> Date: Mon Apr 27 10:40:13 2020 -0400 Merge branch 'sshmodule' of ssh://SERVER.TLD/var/lib/puppet/puppetel7 into ntp commit c0bebffe984d037c0b9b64be5e162a425274b02f Merge: fb2a5d8 2f26e6d Author: USER <email@domain.tld> Date: Mon Apr 27 10:40:06 2020 -0400 Merge branch 'production' of ssh://SERVER.TLD/var/lib/puppet/puppetel7 into ntp commit fb2a5d8558e0bdfbeba66552065845e64a9d7b00 Author: USER <email@domain.tld> Date: Mon Apr 27 10:39:20 2020 -0400 added ntp to profile base
If you only want one commit or change you can use cherry-pick and the commit ID from the log:
git cherry-pick fb2a5d8558e0bdfbeba66552065845e64a9d7b00
Finished one cherry-pick. [production 9510119] added ntp to profile base 1 files changed, 1 insertions(+), 0 deletions(-)