Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ You can not ignore the seven Git tips     - Nodejs complete installation instructions for Express (Linux)

- Understanding Linux firewall Iptables (Linux)

- To install and use Docker under linux (Server)

- Limit the use of the request being Nginx Flood attack (Linux)

- Linux under HAProxy + Keepalived dual-availability program (Server)

- Vim useful plugin: EasyGrep (Linux)

- Linux Systems Getting Started Learning: Configuration PCI passthrough on a virtual machine (Linux)

- C # asynchronous delegates (Programming)

- Efficient Linux Shell - Shell special characters Summary (Linux)

- MySQL Study of --Percona Server 5.5 Upgrade 5.6 (Database)

- VMware Workstation virtual machine Ubuntu achieve shared with the host (Linux)

- Weld a problem in JDK 8u60 environment (Programming)

- Install Linux Mint 17: 20 things to do (Linux)

- ImageMagick Tutorial: How to cut images in Linux command line (Linux)

- How to find out a Unix system library files are 32-bit or 64-bit (Linux)

- MySQL and Oracle time zone settings compare (Database)

- Linux system security configuration (Linux)

- Linux terminal interface font color settings (Linux)

- How to use tmpfs in RHEL / CentOS 7.0 (Linux)

- ActiveMQ configuration Getting Started Tutorial (Server)

 
         
  You can not ignore the seven Git tips
     
  Add Date : 2018-11-21      
         
       
         
  Program development version control is essential, Python developers, too. The version control system, currently the most widely used, probably Git, and its most famous representative is Github. This translation was to introduce the seven Git tips, the goal is to facilitate programmers to make up for their mistakes committed in development.

Compared with other technologies, Git should save their jobs more developers. As long as you regularly use Git to save your job, you always have the opportunity to return the code to a previous state, so you can save those mistakes you committed the night stumbled.

Having said that, Git command line interface, but notoriously difficult to master names. Next, we give you about seven small tips to maximize the role of Git.

Typically, most of the time we only use add, commit, branch, and push / pull these commands. Most people are familiar with this only in one direction running workflows. Have you ever thought, if they add to the warehouse the wrong file, or code submitted to the wrong branch, and submit the information also wrong, then how can cancel their own before the operation? If you follow the above cartoon is depicted in the same operation (ie delete the local project folder, and then re-download the warehouse), then you have the need to understand the following Git tips.

1. Modify the wrong information submitted (commit message)

Submit information for a long time will remain in your code library (code base), so you certainly hope that this information is correct understanding of the code changes the situation. The following command allows you to edit one of the recently submitted information, but you must make sure that no current code base (working copy) to make changes, otherwise the changes will also be submitted together.

$ Git commit --amend -m "YOUR-NEW-COMMIT-MESSAGE"
If you have already submitted the code (git commit) Push (git push) to the remote branch, then you need to push through the following command to force the code delivery.

$ Git push --force
Follow this Q & Stack Overflow website for more details.

2. Before submitting undo git add

If you go to the staging area (staging area) added some wrong files, but has not yet submitted the code. You can use a simple command can be revoked. If you only need to remove a file, enter:

$ Git reset
Or if you want to remove all failed to submit modifications from scratch:

$ Git reset
Follow this Q & Stack Overflow website for more details.

3. Undo Last Submit Code

Sometimes you might accidentally submitted the wrong file or start missing something. The following three steps can help you operate to solve this problem.

$ Git reset --soft HEAD ~ 1
# Working papers necessary changes
$ Git add -A.
$ Git commit -c ORIG_HEAD
When you execute the first command, Git will HEAD pointer (pointer) Moves to the previous commit, then you can move a file or make the necessary changes.

Then you can add all the changes, but when you execute the last command, Git will open your default text editor, which will contain information about the last commit. If you wish, you can modify the submitted information, or you can use -C instead of -c in the final command to skip this step.

4. Git repository state to withdraw before the time of submission

"Undo" (revert) in many cases is very necessary - especially if you put the code out of the mess of the case. The most common situation is that you want to return to the previous version of the code, check the code base at that time, and then return to the present state. This can be realized through the following command:

$ Git checkout
"" You want to submit the hash value has (Hash Code) in front 8-10 characters view. This command causes pointer off (detach), so you can not be detected (check out) to see the code in any branch of the case - from HEAD is not as scary as it sounds. If you want to submit this case to modify, you can create a new branch to achieve:

$ Git checkout -b
To return to the current progress of the work, only you need to check out (check out) before you can branch location.

Follow this Q & Stack Overflow website for more details.

5. Undo Merge (Merge)

To undo the merger, you may have to use the restore command (HARD RESET) back to the state last submitted. "Merge" the work done is basically resetting the index, update working tree (working tree) in different files that the current submission () code and HEAD cursor file code between different points; but the merger would retain the index differences part (for example, those that have not been tracked changes) and between the working tree.

$ Git checkout -b
Of course, Git there is always another way to accomplish this, you can see the look of this article to obtain more information.

6. Remove unused files from the current track local Git branch

Suppose you happen to have some untracked files (because they are no longer needed), you do not want every time git status command so that they appear to use. Here are some ways to solve this problem:

$ Git clean -f -n # 1
$ Git clean -f # 2
$ Git clean -fd # 3
$ Git clean -fX # 4
$ Git clean -fx # 5
(1): The -n option displays the execution which files will be removed (2).
(2): The command will remove all commands (1) shown in the document.
(3): If you want to remove a file member, please use the option -d.
(4): If you want to remove have been ignored files, use the option -X.
(5): If you want to remove have been ignored and not ignored files, use the option -x.
Please note that the last two commands X differences.

7. Delete local and remote Git branch

Remove Local branches:

$ Git branch --delete --force
Or use the -D option as shorthand:

$ Git branch -D
Delete remote branch:

$ Git push origin --delete
     
         
       
         
  More:      
 
- How comprehensive resist attacks from the network (Linux)
- Understanding the type in C ++ bitset (Programming)
- After VMware CentOS full VM clone the network card is unavailable Solutions (Linux)
- Ubuntu and Archlinux install Notepadqq 0.50.2 (Linux)
- JavaScript basic tools list (Programming)
- What happens after the MySQL disk space is full (Database)
- CentOS build JDK environment (Linux)
- Use PXE with kickstart to install Linux automatically (Linux)
- Replace element and non-replaced elements of learning (Programming)
- SecureCRT in Python scripting study guide (Programming)
- Process safety monitoring and protection under the Linux operating system (Linux)
- Ubuntu clean up unnecessary disk space usage (Linux)
- Enterprise Hadoop cluster architecture - Hadoop installation (Server)
- Element content of Java HashSet change issues (Programming)
- Appweb configuration in detail (Server)
- Use py2exe to generate exe files Python script (Programming)
- Installation and use the telnet command under CentOS 6.x (Linux)
- Apache Tomcat integration and resin (Server)
- Install Oracle JDK 8 and JVM class loading mechanism in Linux (Linux)
- To install CentOS 6.5 on your hard drive under Windows 7 (Linux)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.