common git commands

本文详细介绍了如何使用Git进行项目管理,包括如何通过三种方法更改Git项目的代码,如何在一个命令中添加多个文件到暂存区,以及Git在分支工作流程中的常用命令。此外,还提供了关于如何在协作工作中使用Git的实用命令。

1. Three ways to undo changes made to Git project

  •     git checkout HEAD filename: Discards changes in the working directory
  •     git reset HEAD filename: Unstages the file changes in staging area
  •     git reset SHA: used to reset to a previous commit in the commit history

 

2. add multiple files to staging area with single command

    git add filename_1, filename_2

 

3. Useful commands in git branch workflow

  • git branch : List all Git project's branches
  • git branch branch_name : Create a new branch
  • git checkout branch_name : Switch from one branch to another
  • git merge branch_name : Join file changes from one branch to another
  • git branch -d branch_name : delete a specified branch

4. Use commands in Git Collaborative Workflow

  • git clone : create a local copy of a remome
  • git remoe -v : Lists a git project's remotes
  • git fetch : Fetches work from remote into local copy
  • git merge origin/master : Mergers origin/master into the local branch
  • git push origin <branch_name> : pushes a local branch to the origin remote

转载于:https://www.cnblogs.com/li-hongjie/p/5061940.html

MobaXterm is a popular enhanced terminal for Windows that includes many useful features, including an integrated Git client. With MobaXterm, you can easily manage your Git repositories and perform common Git operations directly from the terminal. To use Git in MobaXterm, you first need to make sure that Git is installed on your system. You can install Git by downloading it from the official website (https://git-scm.com/) and following the installation instructions. Once Git is installed, you can open MobaXterm and navigate to the directory where your Git repository is located. You can use the "cd" command to change directories. For example, if your repository is located in the "Documents" folder, you can use the following command: ``` cd Documents ``` Once you are in the correct directory, you can use Git commands to interact with your repository. Here are some common Git commands you can use: - `git clone <repository_url>`: Clone a remote Git repository to your local machine. - `git add <file>`: Stage changes in a file for a commit. - `git commit -m "<commit_message>"`: Create a new commit with the staged changes. - `git push`: Push your local commits to a remote repository. - `git pull`: Fetch and merge changes from a remote repository into your local branch. - `git status`: Show the current status of your repository. Remember to replace `<repository_url>` with the actual URL of your Git repository and `<file>` with the name of the file you want to add or commit. It's worth mentioning that MobaXterm also provides a graphical user interface (GUI) for managing Git repositories. You can access it by clicking on the "Tools" menu and selecting "Git GUI" from the dropdown. I hope this helps! Let me know if you have any further questions.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值