GIT: Difference between revisions
(→GIT) |
|||
Line 1: | Line 1: | ||
=GIT= | =GIT= | ||
Links | |||
* https://git-scm.com/book/en/v2 | |||
* https://www.atlassian.com/git/tutorials/learn-git-with-bitbucket-cloud | |||
== Create Master GIT Repository == | == Create Master GIT Repository == | ||
Line 97: | Line 102: | ||
git pull --rebase <branch to merge> | git pull --rebase <branch to merge> | ||
== Revert == | |||
git revert <hash-or-ref> | |||
== Reset == | |||
Make sure you are on the branch where the commit is. | |||
Then use git reset –hard <commit-hash> to set the current branch HEAD to the commit you want. | |||
git reset --hard cedc856 | |||
git push --force origin <branch> | |||
When we push the change to origin when need to use force | |||
=SALT + GIT= | =SALT + GIT= |
Latest revision as of 00:02, 25 April 2019
GIT
Links
- https://git-scm.com/book/en/v2
- https://www.atlassian.com/git/tutorials/learn-git-with-bitbucket-cloud
Create Master GIT Repository
On the GIT master repository:
1. Create directory
mkdir -p /opt/gitbase.git
2. Initialize (--bare means ignore it is empty/initial)
git init --bare
Get GIT Repository
3. Clone the repository 3.1 GIT master is on the same host
git clone /opt/gitbase
3.2 if on remote host via SSH
git clone hostname01:/opt/gitbase
4. Make changes to the local copy
cd gitbase vi SomeFile.txt (change save and close or copy some files here)
5. Add the new or modified file to the git tree
git add *
6. Commit the changes
git commit -m 'first commit'
7. Push the changes upstream
git push -u origin master
HINT: Step 5 and 6 can be combined in one step by exec
git commit -a
Update the local repository (example SK SALT master)
8. Pull the latest version
git pull
9. make some changes and commit (Steps 4-7)
That's it
REVERT BACK CHANGES
git reset 4579a7fd4e
The 4579a7fd4e are the first 10digits of the commit you want to revert to
Now update your local file
git checkout -- hello.sh
git push -f -u origin master
Add Project to GIT
cd /dir/project git init git add . git commit -m 'Initial GIT SK Saltstack Branch' -a
Push to the master
- on same server
git remote add origin /<path to git master>
- on remote server
git remote add origin ssh://git@remote-server/<path to git master>
- then push the changes
git push origin master
- if the above fails because there is already something checked in
git push -f origin master
git pull origin <branch to merge> --allow-unrelated-histories git push
Merge branch to master
git checkout master git merge <branch to merge>
git -d <branch to merge>
Rebase
git pull --rebase <branch to merge>
Revert
git revert <hash-or-ref>
Reset
Make sure you are on the branch where the commit is.
Then use git reset –hard <commit-hash> to set the current branch HEAD to the commit you want.
git reset --hard cedc856 git push --force origin <branch>
When we push the change to origin when need to use force
SALT + GIT
1. create master repository somewhere
2. checkout the repository and create a directory structure
sk/salt pl/salt ie/salt at/salt
etc
3. Put in the structure the salt configuration for the affiliate
sk/salt/srv/pillar/ sk/salt/srv/salt/
4. Commit and push the changes to the master
5. on the Salt servers checkout the branch you need
cd / git clone hostname01:/opt/gitbase/sk/salt/srv
FILESRV BACKEND GIT
The fileserver backend makes the local copy (configuration obsolate)
fileserver_backend: - git gitfs_provider: pygit2 gitfs_remotes: - file:///opt/gitbase gitfs_root: sk/salt
This means the SALT master will look for the files in the git repository (in the above example on local fs) You can however point to the GIT master you use.
gitfs_remotes: - https://github.com/saltstack-formulas/salt-formula.git
gitfs_remotes: - git@github.com:user/repo.git - ssh://user@domain.tld/path/to/repo.git
https://docs.saltstack.com/en/latest/topics/tutorials/gitfs.html
You can add local repository via
fileserver_backend: - git - root