顯示具有 git 標籤的文章。 顯示所有文章
顯示具有 git 標籤的文章。 顯示所有文章

2017年6月19日 星期一

2017年4月11日 星期二

[git] Merge with branch

Merge master into the development first so that if there are any conflicts, I can resolve in the development branch itself and my master remains clean.


(on branch development)$ git merge master
(resolve any merge conflicts if there are any)
git checkout master
git merge development (there won’t be any conflicts now)


Reference:

2017年3月21日 星期二

2016年12月28日 星期三

2016年9月12日 星期一

2016年3月29日 星期二

2016年3月28日 星期一

[Git] How to add submodule and git push under submodule

Origin git folder
/tmp/test

Add submodule

Under git folder add another module.
git submodule add ssh://happy@127.0.0.1:/run/media/git/happy.git  bundle/happy

ls display one more folder was called happy.
/tmp/test/bundle/happy

git commit .gitmodules
git commit bundle/happy

git push #Finish add submodule

Remove submodule

# Remove the submodule entry from .git/config
git submodule deinit -f path/to/submodule

# Remove the submodule directory from the superproject’s .git/modules directory
rm -rf .git/modules/path/to/submodule

# Remove the entry in .gitmodules and remove the submodule directory located at path/to/submodule

git rm -f path/to/submodule

Under submodule - Git push

Change to /tmp/test/happy.
cd /tmp/test/happy

Add file was called test.txt
under /tmp/test/happy, then type git add & git commit & git push will push to ssh://happy@127.0.0.1:/run/media/git/happy.git

Reference:

2015年12月21日 星期一

[Git] Remove useless file from commit history

  1. Clone git from git repository
    git clone https://github.com/XXXX.git

  2. cd XXXX

  3. Remove
[freeman@localhost snmp]$ git filter-branch --force --index-filter \
> 'git rm --cached --ignore-unmatch     happy/good/*.pdf' \
> --prune-empty --tag-name-filter cat -- --all 
Rewrite 3c970f1a6def691845f26a4dae0522a9edfcaa23 (8/8)rm 'happy/good/doc/haha.pdf'

Ref 'refs/heads/EVW3226-211_SNMP_Trap_feature_request' was rewritten
WARNING: Ref 'refs/heads/master' is unchanged
Ref 'refs/remotes/origin/EVW3226-211_SNMP_Trap_feature_request' was rewritten
WARNING: Ref 'refs/remotes/origin/master' is unchanged
WARNING: Ref 'refs/remotes/origin/master' is unchanged



4. Clean cache and recycle space

rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now



5. Force to commit
git push origin master –force



Reference”

2015年10月27日 星期二

[git] Local git repository push to new repository on github, and keep commit log

1. Remove remote repository
git remote rm origin

2. Go to local git repository and add remote repository of github
git remote add origin git@github.com:haha/ip.git
or
git remote add origin /home/happy/git/doc

3. Push to remote repository of github
git push --set-upstream origin master --force


Reference:

2015年10月18日 星期日

[Git] How to compile git source code on Fedora 12

Q:
[root@localhost tmp]# git clone https://github.com/frgtn/rpcapd-linux
Initialized empty Git repository in /tmp/rpcapd-linux/.git/
error: The requested URL returned error: 403 while accessing https://github.com/frgtn/rpcapd-linux/info/refs

fatal: HTTP request failed

Please update git version.

1.
Download latest version

2. tar xvf git-2.6.2.tar.gz
cd git-2.6.2
./configure
make && make install


Reference:


Q :
make: Warning: File `config.mak.uname’ has modification time 8.8e+05 s in the future
A :
ntpdate time.nist.gov

2015年7月17日 星期五

[GIT] How to git push multi repository


Method 1:
Syntax :

git config alias.pushall '!f() { git push <remote-name> $1 && git push <remote-name> $1; }; f'

Example :

git config alias.pushall '!f() { git push origin $1 && git push openvpn $1; }; f'


Method 2:
Edit .git/config
[alias]
    pushall = "!f() { git push origin $1 && git push openvpn $1; }; f"
cat .git/config
[openvpn]$cat .git/config
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = ssh://
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[remote "openvpn"]
    url = ssh://
    fetch = +refs/heads/*:refs/remotes/openvpn/*
[alias]
    pushall = "!f() { git push origin $1 && git push openvpn $1; }; f"

Add more repository
Example:

git remote add vpn ssh://gogo@192.168.0.1:/home/sasa/git/vpn.git
Reference:
  1. Git - Pushing code to two remotes [duplicate]

2015年4月28日 星期二

2015年4月1日 星期三

2015年3月27日 星期五

[Github] update the lastest commit of submodule

Update the lastest commit of submodule
cd framework
git checkout master
git pull
git submodule update --init --recursive

add git alias for update the lastest commit of submodule
git config --global alias.up-sub-snipmate-snippets '!f() { cd bundle/snipmate-snippets && git checkout master && git pull && git submodule update --init --recursive; }; f'

Reference:

2015年3月26日 星期四

[git] git clone –mirror && git clone –bare

Method A : git clone –mirror
Method B : git clone –bare

Method A :
git clone –mirror to local
Go to another folder, git clone form local repository.
git push to local repository.
Go to local repository then type git push to push the commit to remote.

[core]
    repositoryformatversion = 0
    filemode = true
    bare = true
[remote "origin"]
    url = ssh://happy@168.95.1.1/home/happy/git/test
    fetch = +refs/*:refs/*
    mirror = true

Method B :
git clone –bare to local
Go to another folder, git clone form local repository.
git push to local repository.
Go to local repository then type git push to push the commit to remote.

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = ssh://happy@168.95.1.1/home/happy/git/test
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

Compare :

method A
When I git push under method A. git push no ask any question.

method B
When I git push under method B. git push ask question and type following command at the first push.
git push –set-upstream origin master

After push you can find log have keywork "merge". Because git clone --bare clone the repository to become a independent one. So even remote and local repository are the same content. When push from local to remote need to merge together. But mirror don't need.
That is the different.

Reference:
- Duplicating a repository

2015年3月21日 星期六

2015年3月17日 星期二

2014年12月8日 星期一

[Git][Bitbucket] Modify remote URLs to another

Already have a Git repository on your computer? Let’s push it up to Bitbucket.
1. cd /path/to/my/repo
2. git remote set-url origin https://happy@bitbucket.org/happy/happy.git
3. git push -u origin –all # pushes up the repo and its refs for the first time
4. git push -u origin –tags # pushes up any tags
Update local repository finish now.


Reference :
1. Changing a remote’s URL

2014年11月20日 星期四

2014年11月5日 星期三

[Git] Show where does the git fetch url from

[Git] Show where does the git fetch url from

git remote show origin
* remote origin
Fetch URL: ssh://haha@git.gogo:/haha/git/project
Push URL: ssh://haha@git.gogo:/haha/git/project
HEAD branch
: (unknown)
Local branch configured for 'git pull':
master merges
with remote master



Reference:

1.How can I determine the url that a local git repo was originally cloned from?