GIT and work scenarios

Time:2019-12-2

GIT and work scenarios

Version control git, combined with git problems in the work.

At eight o’clock in the morning, Xiaoji opened her eyes, put her arms out on the back of her head, thinking about the girl she met in the bar last night.

Xiaolei’s humor on the bar and the dim and warm lights of the bar made the girl laugh like a bell. They talked about their work and their life ideals

The girl asked him: what do you think is the purpose of life

Xiaolei raised his head 45 degrees and said slowly: work hard and study hard to ensure a better life, gain self-confidence and happiness, and be able to take care of the people I care about most, so that I can more focus on pursuing my life ideals and significance.

The girl looks at the boy with infatuated eyes who is young and handsome in appearance and mature in heart.

It’s time for me to go. Let’s talk again when we have a chance. Xiaoji said that she picked up her computer bag and was ready to leave.

Well, my bed has collapsed. Can I stay with you tonight? The girl chased after her and then turned shyly.

Looking at the petite and pitiful back, the girl’s light jasmine is eroding my brain, head.

When Xiaolei was about to promise, his mother asked him not to take strangers home. He touched the girl’s head and said that my bed was too small.

I’m glad that I didn’t promise to take her back to sleep last night, otherwise it’s too crowded for two people to sleep in a one meter wide bed in the rental house. If they don’t sleep well, they will not be able to work the next day.

At this time, the voice of my co rented classmates brought me back to reality. I had to go to Tiantongyuan to squeeze the subway.

Turn on the computer, turn on the left and right display screens for a day’s work

Scene 1

Tech boss: the new function you developed last time can be tested on the main branch.
As follows:
GIT and work scenarios

Operation:

  1. First, keep the workspace on your dev Branch clean — commit git add to the temporary storage, and then git commit – m to the GIT warehouse
  2. Switch to main and pull the latest code — git checkout main & git pull
  3. Merge the code above dev into main — git merge dev

If the conflict does not merge randomly at this time, avoid being beaten by other colleagues. Ask about every conflict you are not sure about when you operate it correctly.

Situation two

Technology boss: you last developed the new functions (1, 2, 3, three small functions) and test the 2 functions on the main.
as follows
GIT and work scenarios
Operation:

  1. First, keep the workspace on your dev Branch clean — commit git add to the temporary storage, and then git commit – m to the GIT warehouse
  2. Switch to main and pull the latest code — git checkout main & git pull
  3. View the version number submitted by iss55 — git reflog

GIT and work scenarios

  1. Take out the submission with cherry pick — git cherry pick 84d2f15

Resolve the conflict

Situation three

When you are working on a certain part of the project, the things in it are in a messy state, and you want to go to other branches to do some work. The problem is, you don’t want to submit half the work done, or you won’t be able to return to this work point in the future. The solution to this problem is the GIT stash command.

Form a good habit to check the status of GIT status before each operation. (Fig. 1)
GIT and work scenarios

Git diff when you want to know what changes have been made to the file (Figure 2)

GIT and work scenarios

Now you can start showing,
Using git stash (Figure 3)

GIT and work scenarios
See if your workspace is clean, you can switch to other branches. If you can’t switch branches in Figure 1, you can try.
Finally, back to this branch, use git stash apply to use the latest storage by default. You can also use git stash list to see the storage in it

Git command ranking, regardless of order:

  1. git status
  2. git diff
  3. git add
  4. git pull
  5. git commit
  6. git push
  7. git checkout
  8. git reset
  9. git merge

Remember, anything that has been committed to git can be recovered. Even commits in deleted branches and rewritten commits can be recovered (see Chapter 9 for the content of data recovery). So, the data you may lose is limited to uncommitted data, which for Git is as if it never existed.

Git book transfer