newdevs:git:commands
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
newdevs:git:commands [2019/06/28 17:10] – created tmccanna | newdevs:git:commands [2024/03/25 16:35] (current) – tmccanna | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Git for Windows | + | **New Developers Working Group** |
- | ===== Useful Git Bash Commands ===== | + | ====== |
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | ==== Rebase | ||
+ | |||
+ | If your patch is behind current main, you'll need to rebase it. | ||
+ | |||
+ | - Open the git branch | ||
+ | - Type: git rebase origin/main --> rebases the current branch to main (you can do this when you have your branch checked out and changes committed, but have not yet pushed it) | ||
+ | - If there are merge conflict errors, type: git status | ||
+ | - Open the file with the problem in your preferred text editor (notepad++, vim, nano, etc.) | ||
+ | - Look for merge conflict markers in the file (>>> | ||
+ | - Type: git add (problem file name) | ||
+ | - Repeat steps 4-6 for each additional problem file | ||
+ | - Type: git rebase < | ||
+ | |||
+ | |||
+ | ==== Squash Commits | ||
+ | |||
+ | If you have multiple commits in your local branch that you'd like to combine: | ||
+ | |||
+ | - Use 'git log' to verify that the commits you want to combine are the most recent | ||
+ | - Type '' | ||
+ | - Your text editor will open and should show both of the commits, for example: | ||
+ | * pick 014e59c579 LP#1839359 Select element on login not accessible | ||
+ | * pick 9de92lsi9a LP#1839359 Select element on login not accessible | ||
+ | - Change the word " | ||
+ | * squash --> merges commits, then allows amendment of commit message | ||
+ | * fixup --> merges commits like squash does, but discards previous commit message | ||
+ | - Use "git commit --amend" | ||
+ | - Push the changes up to your remote working directory as normal | ||
+ | * '' | ||
+ | |||
+ | If you've already pushed multiple commits up to your remote working git repository, you can still combine them: | ||
+ | |||
+ | - Follow the steps above, but when pushing, use " | ||
+ | * '' | ||
+ | |||
+ | |||
+ | ==== Common | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | ==== Vim Text Editor ==== | ||
+ | |||
+ | The vim text editor is built into the bash console (similar to notepad in Windows). | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | Vim opens in command mode, which allows a variety of functions, but does not allow direct editing. | ||
+ | * '' | ||
+ | * '' | ||
+ | * '': | ||
+ | * '': | ||
+ | * '': | ||
+ | * '': | ||
+ | * ''? | ||
- | **Git Commands** | ||
- | * git add myfile.txt --> stage a specific file | ||
- | * git add -A --> stage all modified files in the current directory and subdirectories | ||
- | * git add . --> (Note the period) stage all modified files in the current directory but not subdirectories | ||
- | * git branch --> list existing local branches | ||
- | * git branch mynewbranch --> create a new branch | ||
- | * git branch -m oldbranchname newbranchname --> change name of branch | ||
- | * git branch -D branchname --> delete a local branch (cannot delete a branch you currently have checked out, so switch to different branch first) | ||
- | * git checkout mybranch --> check out an existing branch | ||
- | * git checkout -b mynewbranch --> create a new branch and check it out at the same time | ||
- | * git checkout master --> switch to master branch | ||
- | * git checkout -- docname.tt2 --> resets a file you've changed back to its original state (like an undo / revert changes command) | ||
- | * git clone < | ||
- | * git commit --> invoke the default text editor to add a commit message | ||
- | * git commit -m "my commit message" | ||
- | * git commit < | ||
- | * git commit < | ||
- | * git commit -a --> combine the git add and git commit steps into a single step (does //not// include newly created files) | ||
- | * git config < | ||
- | * git config < | ||
- | * git fetch < | ||
- | * git help --> access the built-in Git help documentation. | ||
- | * git log < | ||
- | * git pull --> imports all updates from your default remote repo to your default local repo (usually, this is equivalent to 'git pull origin master' | ||
- | * git pull origin master --> import all updates from remote origin repo to local master repo | ||
- | * git pull < | ||
- | * git push working mybranchname --> push changes to the remote working directory | ||
- | * git push working < | ||
- | * git remote -v --> display remote directories | ||
- | * git reset HEAD myfile.txt --> unstage a file that has already been staged | ||
- | * git reset < | ||
- | * git rm badfile.txt --> delete a file (if the file is being tracked, be sure to add a commit message indicating the file has been deleted) | ||
- | * git show < | ||
- | * git status --> display status of current branch | ||
- | * git version --> displays the installed version of Git | ||
- | **Other Commands** | ||
- | * cd --> move back to the home folder | ||
- | * cd foldername --> move from the current folder to a child folder | ||
- | * cd .. --> move up in the folder hierarchy one level | ||
- | * clear --> clears your command window giving you a fresh screen to work with | ||
- | * ls --> list all of the folders and files in the current folder | ||
- | * mkdir newfoldername --> create a new folder | ||
- | * notepad++ newdocname.txt --> create a new file and open it in notepad++ | ||
- | * notepad++ docname.txt --> edit an existing file in notepad++ | ||
- | * pwd --> see what folder you are currently in | ||
newdevs/git/commands.1561756212.txt.gz · Last modified: 2022/02/10 13:34 (external edit)