-
Notifications
You must be signed in to change notification settings - Fork 1
Git WorkFlow
Ihar Aliakseyeu edited this page Dec 2, 2022
·
10 revisions
Git workflow
- Fetch and merge changes from the remote
- Create a branch to work on a new project feature
- Develop the feature on your branch and commit your work
- Fetch and merge from the remote again (in case new commits were made while you were working)
- Push your branch up to the remote for review
-
git clone <remote_repo_url>copy the remote repository to your local environment, to your computer
A .gitignore file lets Git know which files, folders, and patterns to ignore, and not track them.
- create a '.gitignore' file in the root folders
- add comments '# my comment'
- file names 'thumbs.db'
- folder names 'node_modules/' to exclude all entire files in it ... for more see patterns
-
git fetchFetches work from the remote into the local copy. -
git merge origin/mainMerges origin/master into your local branch.
-
git branch <local_feature_branch>create a branch for the new feature -
git checkout <local_feature_branch>go to the new feature branch or -
git checkout -b <local_feature_branch>all the same, only in one command
- work
-
git statuscheck which files have been modified -
git add <updated_file_1>add the modified file to the stage-
git add <updated_file_1> <updated_file_2>add the modified few files to the stage -
git add .add the all modified files to the stage
-
-
git reset HEAD -- <updated_file_2>remove the unnecessary file from the stage -
git commit -m "Comment"save modifications from stage to commit - if foget smth not significant
git commit --amend --no-edit
-
git stashhide the generated changes in the branch git checkout main-
git fetchfetches work from the remote into the local copy. -
git merge origin/mainmerges origin/master into your local branch. git checkout <local_feature_branch>git merge main-
git stash popextract modifications from stash
git checkout maingit fetchgit merge origin/maingit checkout <local_feature_branch>git merge main- fix conflicts if they appear
-
git commit -m "Resolve conflict"if conflicts was appeared - if foget smth not significant
git commit --amend --no-edit
or with rebase
As a golden rule, it’s important to only use 'git rebase' on a local branch that we’re working on individually.
...still needs to be practically verified.
git rebase- solve conflicts
-
git rebase --continueonce you are satisfied with your changes
-
git push origin <branch_name>pushes a local branch to the origin remote. - create a Pull Request
following commands
- 'git remote -v' : Lists a Git project’s remotes.
- 'git log --oneline --graph --decorate --all' : nice view of commit history