
Git命令 
远程仓库地址 
查看远程仓库地址 
shell
git remote -v设置远程仓库地址 
shell
git remote set-url origin <new-url>查看config配置 
shell
git config --list拉取指定分支代码 
拉取远程的dev分支到本地
shell
 git clone -b dev git@gitee.com:lzh1995/git-demo.git本地创建分支并切换 
shell
git checkout -b 新分支名分支 
查看远程分支 
shell
git branch -r查看本地分支 
shell
git branch切换本地分支 
shell
# 切换到名为branch_name的branch
git checkout branch_name
 
# 创建并切换到名为branch_name的branch
git checkout -b branch_name拉取远程地址的分支并创建本地分支 
比如远程分支有10个,我们想在本地全部给拉取下来。
shell
for branch in $(git branch -r | grep 'origin/' | grep -v '\->'); do
    git checkout -b "${branch##*/}" "$branch";
done将本地全部的分支推送到远程 
shell
git push --all origin取消文件的git版本管理 
由于粗心,没有仔细检查,忘记把1.txt 文件给忽略掉,没有写在.gitignore中, 导致推送到了git仓库,现在我已经将1.txt写到了.gitignore中。应该如何做?
注意: 重点是将本地的文件取消掉git版本管理,然后推送到远程仓库即可!!所以下面的方法适用于下面的情况
1.删除远程分支文件保留本地文件 
 2.取消已经add的 文件/文件夹
 3.取消已经commit本地的 文件/文件夹
 4.删除已经commit远程的 文件/文件夹
- 先从 Git 仓库删除(保留本地文件)
 
shell
# 如果是文件的话需要这样写
git rm --cached 1.txt
# 如果是文件夹的话需要这样写 递归删除 Git 跟踪但保留本地文件
git rm -r --cached xx/- 提交这次删除操作
 
xml
git commit -m "Remove 1.txt from repository"- 推送到远程仓库
 
shell
git push origin <分支名> --force
