GitHub Desktop is a free Git interface tool, the experience is better than Sourcetree, TortoiseGit

What prompted the switch from Sourcetree to GitHub Desktop was the following

  • GitHub Desktop is free, Sourcetree is paid, and there is no need to support legal and jailbreaking.
  • GitHub Desktop supports branch search

GitHub Desktop interface looks simple and easy to use, after in-depth use found that people’s design concept is very close to the use habit of programmers, invisible to the user to reduce a lot of mental burden, and a good fit with GitHub.

GitHub Desktop Program interface

Sourcetree program interface

If you’re new to this job

Clone project to local

File=>Clone a repository=>URL

You may need to enter a user name and password the first time

Create a new branch (Switch branches)

Is asked if the current branch has changed

  • Leave the changes in the current branch
  • Carries changes to the newly created branch

When you select “leave Changes in the current branch”, the Changes are left as “Stashed Changes” in the current branch

Click on it to select “Restore” or “Discard”

Note that “restore” cannot be selected when new changes are made to the branch

When you select “carry changes to the newly created branch”, note that the branch is not pushed remotely, but remains locally and can be used as a local branch

When writing “a function point” on that branch, remember to write “descriptions” when submitting code, and write “descriptions” if necessary.

If your code uses Husky, you may experience the following error

Husky > pre-commit (node v12.14.0) /c/[my_project_path_here]/ClientApp/node_modules/.bin/pretty-quick: line 5: cygpath: command not found internal/modules/cjs/loader.js:800 throw err; ^ Error: Cannot find module '... '... } husky > pre-commit hook failed (add --no-verify to bypass)Copy the code

However, with VS Code’s Git plug-in there is no problem, which may be caused by the need to find the Husky configuration before

{
  "hooks": {
    "pre-commit": "lint-staged",
    "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
  }
}
Copy the code

Use NPX to solve the path problem

{
  "hooks": {
    "pre-commit": "npx lint-staged",
    "commit-msg": "npx commitlint -E HUSKY_GIT_PARAMS"
  }
}
Copy the code

It is possible to “undo” a submission

If the branch has been pushed to the remote, the commit also needs to be pushed to the remote manually

When the branch is finished, for example, when the project is ready to go online, the code needs to be merged into the main branch, which usually needs the approval of the person with the merge permission. At this time, remember to pull the code from the main branch first, and solve the conflict in advance.

When multiple people develop code, conflicts are inevitable, and it’s a good practice to pull code from the main branch in a timely manner

If a conflict occurs, the software displays the conflicting file

When selecting “Open in Visual Studio Code” to Open

  • Adopt current changes
  • Adopt incoming changes
  • Keep both changes
  • Compare the change of

Once the conflict is resolved, select “Continue Merge”

Switch the branch to the test branch and select “Merge into current Branch “.

See the changes

Use “History” to see what changes other members have made

The default is this

You can choose another mode

Drag and drop the commit to another branch

Ctrl, Shift are all about selecting, which is almost universal, and then dragging and dragging the other branches

This feature is useful when iterating through multiple versions simultaneously, solving common problems, or accidentally committing code to a branch like “testing.

Modify or delete branches

The remote branch can be deleted directly

conclusion

Click “File”, “Edit”, “View”, “Repository”, and “Branch” to experience the rest of the functionality

GitHub Desktop is still very thoughtful