git常见问题

如何Create和Clone一个新的 git repo

# 创建一个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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值