# 创建一个remote git repogit init --bare test.git# Clone repogit clone test.git
# 创建一些文件并checkingit add -Agit commit -m "some message"
# 第一次 Push到remote repo的 master branch.git push origin master
如何将local repo连接到新的remote repo# 假设本地已有一个git repo叫test
# 1 - 创建一个新的remote repogit init --bare test.git
# 2 - 回到本地,将remote repo添加的local repogit remote add origin /xxx/test.gi
t# 3 - 初次将所有本地内容push到remote repo上,并建立remote master branchgit push origin master
# 4 - 让本地master branch跟踪remote, 让本地在pull的时候自动与remote branch合并
# Set a local branch to follow the remotegit config branch.[branch-name].remote [remote-name]
# Set it to automatically merge with a specific remote branch when you pullgit config branch.[branch-name].merge [remote-master]
如何删除远程的分支#1 - 假设已经用以下命令建立了一个远程分支git push origin newfeature
#2 - 可以用以下命令删除这个远程分支git push origin :newfeature
#3 - 如果要删除本地分支,可以用以下命令git branch -d newfeature
合并多个commit至一个commit的简单方法切换至主要分支,例如master或releases/R3
git co releases/R3
git fetch # this may be necessary (depending on your git config) to receive updates on origin/mastergit pull
将feature brach合并入主要分支
git merge NS-168
Reset 主要分支至远程origin的状态git reset origin/releases/R3
Git 将unstage所有本地新的更改,然后我们可以将这些在feature_brach的生成的更新作为一个commit
git add .
git add -u # The -u option also adds file deletions.
git commit
修改git commit -m “message”命令
git ci --amend -m “” 只是修改最新添加到git栈中的东西
修改git 获取远程分支以及代码的命令
git co -b origin branchName
git pull -u origin branchName
修改分支名字的命令
git br -m old_branch_name new_branch_name