Git使用

来源:互联网 发布:淘宝助理快递模板设置 编辑:程序博客网 时间:2024/06/02 06:09

1、进入一个文件夹,使其变为管理仓库

git init

2、将文件添加到仓库

git add 文件名

3、将文件提交到本地仓库

git commit -m "自己要加的说明"

4、添加到远程仓库

git remote add origin https://github.com/fonxian/Algorithm.git
git push -u origin master

5、获取远程的分支

$ git pull  https://github.com/fonxian/Algorithm.git  分支名

6、从远程主分支获取最新的版本

git pull


7、将本地的主分支推送到远程的分支上

git push 远程主机名 master:远程分支名


8、解决冲突


<<<<<<< HEADpublic ArrayList<DepartmentVo> getDepartments(Long pid,Long orgId) {if(BaseCache.getInstance().getDeptList(getUId(),pid)==null){ArrayList<DepartmentVo> deptList = contactsDao.getDepartment(getUId().toString(), orgId,getMobile());BaseCache.getInstance().initCache(getUId(), getOrgId(), deptList);}return BaseCache.getInstance().getDeptList(getUId(), pid);}@Overridepublic ArrayList<User> getUsers(Long deptId,Long OrgId,int index,int count ) {ArrayList<User> list = contactsDao.getUsers( getUserId(),OrgId, getMobile(),index,count);=======public ArrayList<DepartmentVo> getDepartments(Long pid) {ArrayList<DepartmentVo> list = BaseCache.getInstance().getDeptList(getUId(), pid);return list;}@Overridepublic ArrayList<User> getUsers(Long deptId, int index, int count) {ArrayList<User> list = contactsDao.getUsers(getUserId(), getOrgId(), getMobile(), index, count);>>>>>>> 365e3857c08ad54842d002ff84891aa97fb8b56c

分割线=====上面的是pull下来的最新的代码,下面的则是我pull下来之前的代码,对比这两部分的代码,删除其中的一段即可。


9、本地提交、远程拉取出错

git branch 查看当前所在的分支,有的时候,远程拉取失败是因为本地分支的当前分支与远程拉取的不符合

可以使用git checkout 来切换分支

10、 git clean -d -fx

删除没有git add 的文件,这个还是谨慎操作

0 0
原创粉丝点击