Some questions and answers about Git

Source: Internet
Author: User
Tags commit config diff sha1 unpack ssh using git

A Chinese display and LS highlighting problem

1 Add LS settings store to/etc/profile solve LS highlighting problem

echo "Alias ls= ' ls--color=tty--show-control-chars '" >>/etc/profile

Echo ' CD ' $HOME ' >>/etc/profile

Description: This is to highlight folders and executables when you use the LS command; Let git bash start and stay below the home path.


2 Add settings to/ETC/INPUTRC solve the problem of displaying Chinese characters in Git bash, and do not solve the problem of Chinese characters annotation in git diff xxx.c

echo "Set Meta-flag on" >>/etc/inputrc

echo "Set Input-meta on" >>/etc/inputrc

echo "Set Output-meta on" >>/etc/inputrc

echo "Set Conver-meta off" >>/etc/inputrc

3 git diff xxx.c show <a8><b9> .... Solving the problem of garbled characters

Git
-----------------

Pro git Chinese online: http://git-scm.com/book/zh/v1
Http://git-scm.com/book/zh/v2
Problem
Troubleshooting

[problem] using Git to merge multiple commits
[Solution] Suppose you want to merge the last 2 commits, you can do this as follows:
1. Git rebase–i head~2
2. Modify the second pick to squash or S, then enter ": Wq" to exit.

Prerequisites, the merged commit cannot have a conflict, if any, git rebase fails.

[Issue] ERROR:SRC Refspec Master does not match any.
[Solution] without a master branch, create a master branch

[problem] Old mode 100644 new mode 100755
[answer] git config core.filemode false
Or
git config--global core.filemode flase
. Repo/repo/repo forall-c git config core.filemode false

[Question]! [Remote rejected] HEAD--Refs/for/refs/heads/indroid4.4-master (change 36303 closed)
[Answer] Two commits the Commit-id repeat, resubmit
This error occurs if you is trying to push a commits that contains the change-id of a closed change in its commit message.
Https://git.eclipse.org/r/Documentation/error-change-closed.html

Problem The middle of an AM session
Troubleshooting

Problem
Troubleshooting
Error:unpack failed:error Missing Tree 64e965a3155d8913b63574138bd568325d25ef91
Fatal:unpack error, check server log
To ssh://hjhong_sz@192.168.1.26:29418/android/kernel/kernel-3.0.8
! [Remote rejected] HEAD--Refs/for/refs/heads/indroid4.4-master (N/A (unpacker error))
Error: Unable to push some references to ' ssh://hjhong_sz@192.168.1.26:29418/android/kernel/kernel-3.0.8 '


[Problem] in Chinese case git status is "\344\272\247\345\223\201\351\234\200\346\261\202" almost like this.
[Solution] git config--global core.quotepath false


[Problem] git patching method
[Answer] git format-patch-s 028e541af040c76a6e
git apply Xxxx.patch

Problem Configure git command auto-complete in CentOS6
[Answer] Http://www.111cn.net/sys/CentOS/65611.htm

[problem] git pull ing indroid4.4-master
You have a not concluded your merge (Merge_head exists).
Please, commit your changes before you can merge.
[Answer] git commit-m "temp" && git reset--hard head~1

Problem
[Answer] git diff--cached

[question] git pull default configuration how to do it.
Troubleshooting
git config branch.working.remote os
git config branch.working.merge indroid4.4-master
Or
git pull os indroid4.4-master
In a nutshell, using Git push-u Origin master allows you to pull directly from the previous push to a git pull with no other parameters.


[Question] How to set the git push default configuration.
[Solution] git push-u ing indroid4.4-master


[Issue] Upgrade CentOS6 git 1.7.1 to 1.7.12
[Answer] http://my.oschina.net/heiing/blog/355561

[Problem] git push error
Counting objects:17, done.
Delta compression using up to 4 threads.
Compressing objects:100% (9/9), done.
Writing objects:100% (9/9), 916 bytes, done.
Total 9 (Delta 8), reused 0 (Delta 0)
Remote:resolving deltas:100% (8/8)
Remote:processing Changes:refs:1, done
Remote:ERROR:missing Change-id in commit message footer
Remote:suggestion for Commit message:
Remote:ulps:fix power consume increasing problem when exit Ulps
Remote
Remote:change-id:i7faa12ff904202c3ed6d8e334fddec1af50e3b60
Remote
Remote:Hint:To automatically insert Change-id, install the hook:
remote:gitdir=$ (git rev-parse--git-dir); Scp-p-P 29418 mlwang_sz@gerrit.ingenic.com:hooks/commit-msg ${gitdir}/hooks/
Remote
Remote
To Ssh://mlwang_sz@194.169.1.26:29418/sw1/slpt
! [Remote rejected] master, Refs/for/refs/heads/master (missing Change-id in commit message footer)
Error:failed to push some refs to ' ssh://mlwang_sz@194.169.1.26:29418/sw1/slpt '
ingenic@studentworks:/media/data/slpt$ git commit--amend
[Master 3ce3724] Ulps:fix power consume increasing problem when exit Ulps
2 files changed, insertions (+), deletions (-)

Troubleshooting
ingenic@studentworks:/media/data/m200_android_4_3/bootable/bootloader/uboot$ CP. Git/hooks/commit-msg/media/data /slpt/.git/hooks/-VF
'. Git/hooks/commit-msg ', '/media/data/slpt/.git/hooks/commit-msg '
ingenic@studentworks:/media/data/slpt$ chmod +x. git/hooks/commit-msg
ingenic@studentworks:/media/data/slpt$ git commit--amend


[question] How to make git output color into color
[Solution] Use the following configuration code
git config--global color.status auto
git config--global color.diff auto
git config--global color.branch auto
git config--global color.interactive auto

0. Submit the code and synchronize the code
Commit code is submitted to the code warehouse in Beijing. Cat. Git/config [Remote OS] represents the Shenzhen code base, [remote "ing"] represents the Beijing code base
Synchronization code, is from the Shenzhen Code warehouse synchronization.

1. View git status
git status
2. Save the current directory
Git stash

Set the global user name and mailbox
git config--global user.name "username"
git config--global user.email "email"
git commit--amend--reset-autho
Set the user name and mailbox for the current Git repository
git config user.email maolei.wang@ingenic.com
git config user.name maolei.wang
Set the commit default editor
Export Editor=vim or a different approach
Edit. Git/config, in core, add editor = Vim


3. Change the GIT configuration and set the place where the code is submitted
VI. git/config
[Remote "ing"]
URL = ssh://hhyang_sz@192.168.1.26:29418/android/kernel/kernel-3.0.8
Review = https://review.ingenic.cn/
ProjectName = android/kernel/kernel-3.0.8
Fetch = +refs/heads/*:refs/remotes/ing/*
Push = Head:refs/for/refs/heads/indroid4.3-master

4. Create a new branch
Git branch S2121b_16t_x2_mlwang

5. Switch to the new branch
git checkout S2121b_16t_x2_mlwang

6. Update to the latest code
git fetch--all

7. Pop Up the current branch
Git stash pop

8. Submit the Update Code
git add file1 file2 file3 ....

9. Submit
git commit-m "message"

10. Push Code
git push ing
The name "ing" in the catalog./.git/config


11. View Logs
git log

12. View Status
git status

13. Resubmit (recommit)
git commit--amend
Pop up a vi window, command: Wq save exit


14. View the details of a branch
Git show-branch-a--sha | Less

15. View the configuration of the warehouse
Git config-l

16. Hard Rollback
git reset--hard 66c103f741d09777448a140f4622e058fc5218d3
In the current directory and the latest directory is not the same time, the change commit to local, git diff SHA1 sha2> xxx.patch to generate a patch.
Then use git reset Newest_sha to update the code to the latest node. Use PATCH-P1 Xxx.patch to add your own changes to the newest node.

17. Make patches and patches
Making Patches
git diff sha1 sha2 > mlwang.patch
Hit patch
Patch-p1 <./mlwang.patch

18. See the difference in the two submissions of a file
git diff f2ead7f4bbc A6c6ef00e2 drivers/video/jz_lcd/lcd_panel/auo_x163.c
git diff head Studentworks drivers/video/jz_lcd/lcd_panel/edo_e1392am1.c #其中studentworks是分支名, head is the current commit node
Problem
Remote:resolving deltas:17% (185/1073)
Error:unpack failed:error Missing Tree 79f34925083ccf5367832f4ad49e4aea8f37c20f
Fatal:unpack error, check server log
To ssh://mlwang_sz@192.168.1.26:29418/android/kernel/kernel-3.0.8
! [Remote rejected] HEAD--Refs/for/refs/heads/ingenic-master (N/A (unpacker error))
Error:failed to push some refs to ' ssh://mlwang_sz@192.168.1.26:29418/android/kernel/kernel-3.0.8 '
Solution

"Problem" git status does not show newly added folders
Solution


"Problem" git push after the code to carefully explore the format of the code in Gerrit, especially from other people that copy of the code, not the code you want to submit to abandon out
Solution

"Problem" merged from (no branch) into master
"Resolution" http://blog.csdn.net/zmlovelx/article/details/7464972

"Problem" Recovering a deleted branch, file, or lost commit from a git repository
git checkout [commit_id]--<path_to_file>
Example git checkout 5ee141400d drivers/video/jz_lcd/lcd_panel/auo_x163.c
git checkout studentworks drivers/video/jz_lcd/lcd_panel/edo_e1392am1.c # Studentworks for branch names
Reference: http://sumsung753.blog.163.com/blog/static/146364501201301711943864/

"Problem" undo last commit, with command git status to see what was last submitted
"Fix" git reset--mix head~1

How to synchronize your code
git checkout--track os/indroid4.4-master
Git pull
Or
./repo SYSNC

. Git Package Archive
git archive-o ingenic-master.zip ab70e09c1f5b63fd217d1
Git archive--format tar.gz head-o ~/downloads/kernel.tar.gz

[Question] How to add a local ssh-key to GitHub

Troubleshooting

1. Generate a public key that can be used on GitHub

Ssh-keygen-t rsa-c "Jiankangshiye@xxx.com"

The default can be

2. Add SSH key to GitHub

3. Verify that the SSH key is set successfully

Ssh-t git@github.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.