Repo to practice git methods
sudo apt install git -y
- Set parameters
git config --global.user.name "First Last"
git config --global user.email "[email protected]"
- clone a repo
git clone <url>
- New directory will be in terminal working path
- Up to date with origin/main
git status
cat .git/config
- Create branch
- Make change
- Merge change
-
install vscode
-
Open folder in vscode
code .
- Add a module similar to moduleP
- my_module
- git status
- Shows files that aren't being tracked in red
- git add filename.py
- git add -all
- git status
- Files will now be displayed
- git commit -m 'commit message'
- git status
- Will now be ahead of main
- git push
- Publish local changes
- If there is changes to main since you made the pull you will get a message to pull changes
- git pull
Working on the same branch causes issues with syncing changes
- Set global
- git config pull.rebase false
- git branch
- Shows known branches
- git checkout -b branchName
- Switches to branch
- Creates the branch if it is new
- git branch
- Shows new branch
- Make changes to files in branch
- git add fileName
- Make sure required files are added
- git commit -m 'commit message'
- If new branch
- Create new branch origin
- git push --set-upstream origin branch
- git pull
- git checkout main
- git pull
- git merge --no-ff --no-commit branchName
- --no-ff no fast forward
- --no-commit
- stops before commiting
- git status
- git commit -m 'merged branchName into main'
- git push
- Setting up protections on main will prevents everyone being able to commit to main without getting it approved first
- Only maintainers of the project can make changes on that branch